| 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 | */ |
| | 538 | extern 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 | */ |
| | 546 | extern 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 | } |