Show
Ignore:
Timestamp:
08/03/12 18:26:42 (10 months ago)
Author:
sdsnyde
Message:

added truncate operation to aiocommon. pxfs updated with ftruncate(64)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/asyncio/src/client/usrint/pxfs.c

    r9428 r9432  
    533533*/ 
    534534 
    535 //extern int pxfs_ftruncate (int fd, off_t length, pxfs_cb cb, void *cdat); 
    536  
    537 //extern int pxfs_ftruncate64 (int fd, off64_t length, pxfs_cb cb, void *cdat); 
     535/** 
     536 * pxfs_ftruncate 
     537 */ 
     538extern int pxfs_ftruncate(int fd, off_t length, pxfs_cb cb, void *cdat) 
     539{ 
     540    return pxfs_ftruncate64(fd, (off64_t)length, cb, cdat); 
     541} 
     542 
     543/** 
     544 * pxfs_ftruncate64 
     545 */ 
     546extern int pxfs_ftruncate64(int fd, off64_t length, pxfs_cb cb, void *cdat) 
     547{ 
     548    pvfs_descriptor *pd; 
     549    struct pvfs_aiocb *truncate_acb = NULL; 
     550 
     551    if (fd < 0) 
     552    { 
     553        errno = EBADF; 
     554        return -1; 
     555    } 
     556 
     557    pd = pvfs_find_descriptor(fd); 
     558    if (!pd) 
     559    { 
     560        errno = EBADF; 
     561        return -1; 
     562    } 
     563 
     564    truncate_acb = malloc(sizeof(struct pvfs_aiocb)); 
     565    if (!truncate_acb) 
     566    { 
     567        errno = ENOMEM; 
     568        return -1; 
     569    } 
     570    memset(truncate_acb, 0, sizeof(struct pvfs_aiocb)); 
     571 
     572    truncate_acb->hints = PVFS_HINT_NULL; 
     573    truncate_acb->op_code = PVFS_AIO_TRUNC_OP; 
     574    truncate_acb->u.trunc.pd = pd; 
     575    truncate_acb->u.trunc.length = length; 
     576    truncate_acb->call_back_fn = cb; 
     577    truncate_acb->call_back_dat = cdat; 
     578 
     579    aiocommon_submit_op(truncate_acb); 
     580 
     581    return 0; 
     582} 
    538583 
    539584/*