Changeset 9432

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)

Location:
branches/asyncio/src/client/usrint
Files:
3 modified

Legend:

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

    r9428 r9432  
    197197            break; 
    198198        } 
     199        case PVFS_AIO_TRUNC_OP: 
     200        { 
     201            rc = PVFS_isys_truncate(p_cb->u.trunc.pd->s->pvfs_ref, 
     202                                    p_cb->u.trunc.length, 
     203                                    cred, 
     204                                    &(p_cb->op_id), 
     205                                    p_cb->hints, 
     206                                    (void *)p_cb);  
     207            break; 
     208        } 
    199209        case PVFS_AIO_STAT_OP: 
    200210        {    
     
    309319            free(p_cb->u.rename.newdir); 
    310320            free(p_cb->u.rename.newname); 
     321            break; 
     322        } 
     323        case PVFS_AIO_TRUNC_OP: 
     324        { 
    311325            break; 
    312326        } 
  • branches/asyncio/src/client/usrint/aiocommon.h

    r9428 r9432  
    3636    PVFS_AIO_OPEN_OP, 
    3737    PVFS_AIO_RENAME_OP, 
     38    PVFS_AIO_TRUNC_OP, 
    3839    PVFS_AIO_STAT_OP, 
    3940    PVFS_AIO_STAT64_OP, 
    4041} PVFS_aio_op_code; 
    41  
    4242 
    4343/* the following structures contain operation dependent data for aio calls */ 
     
    8080}; 
    8181 
     82struct PINT_aio_trunc_cb 
     83{ 
     84    pvfs_descriptor *pd;    /* in */ 
     85    off64_t length;         /* in */ 
     86}; 
     87 
    8288struct PINT_aio_stat_cb 
    8389{ 
     
    108114        struct PINT_aio_open_cb open; 
    109115        struct PINT_aio_rename_cb rename; 
     116        struct PINT_aio_trunc_cb trunc; 
    110117        struct PINT_aio_stat_cb stat; 
    111118    } u; 
  • 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/*