Changeset 67e881c in mainline


Ignore:
Timestamp:
2017-03-30T20:59:36Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a56cef9
Parents:
79ea5af
Message:

Rename ftruncate() to vfs_resize()

Location:
uspace
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/trace/trace.c

    r79ea5af r67e881c  
    706706        proto_add_oper(p, VFS_IN_WRITE, o);
    707707        o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def);
    708         proto_add_oper(p, VFS_IN_TRUNCATE, o);
     708        proto_add_oper(p, VFS_IN_RESIZE, o);
    709709        o = oper_new("fstat", 1, arg_def, V_ERRNO, 0, resp_def);
    710710        proto_add_oper(p, VFS_IN_STAT, o);
  • uspace/lib/c/generic/vfs/vfs.c

    r79ea5af r67e881c  
    408408                assert(!(oflag & O_APPEND));
    409409               
    410                 (void) ftruncate(fd, 0);
     410                (void) vfs_resize(fd, 0);
    411411        }
    412412
     
    620620 * @param length Length
    621621 *
    622  * @return 0 on success, -1 on error and sets errno.
    623  */
    624 int ftruncate(int fildes, aoff64_t length)
     622 * @return 0 on success or a negative erroc code otherwise.
     623 */
     624int vfs_resize(int file, aoff64_t length)
    625625{
    626626        sysarg_t rc;
    627627       
    628628        async_exch_t *exch = vfs_exchange_begin();
    629         rc = async_req_3_0(exch, VFS_IN_TRUNCATE, fildes,
    630             LOWER32(length), UPPER32(length));
    631         vfs_exchange_end(exch);
    632        
    633         if (rc != EOK) {
    634                 errno = rc;
    635                 return -1;
    636         }
    637        
    638         return 0;
     629        rc = async_req_3_0(exch, VFS_IN_RESIZE, file, LOWER32(length),
     630            UPPER32(length));
     631        vfs_exchange_end(exch);
     632       
     633        return rc;
    639634}
    640635
  • uspace/lib/c/include/ipc/vfs.h

    r79ea5af r67e881c  
    6565        VFS_IN_READ = IPC_FIRST_USER_METHOD,
    6666        VFS_IN_WRITE,
    67         VFS_IN_TRUNCATE,
     67        VFS_IN_RESIZE,
    6868        VFS_IN_STAT,
    6969        VFS_IN_CLOSE,
  • uspace/lib/c/include/unistd.h

    r79ea5af r67e881c  
    6161extern ssize_t read(int, aoff64_t *, void *, size_t);
    6262
    63 extern int ftruncate(int, aoff64_t);
    64 
    6563extern int close(int);
    6664extern int fsync(int);
  • uspace/lib/c/include/vfs/vfs.h

    r79ea5af r67e881c  
    9090extern int vfs_root(void);
    9191extern void vfs_root_set(int);
     92extern int vfs_resize(int, aoff64_t);
    9293extern int vfs_stat(int, struct stat *);
    9394extern int vfs_stat_path(const char *, struct stat *);
  • uspace/lib/posix/source/unistd.c

    r79ea5af r67e881c  
    259259int posix_ftruncate(int fildes, posix_off_t length)
    260260{
    261         return negerrno(ftruncate, fildes, (aoff64_t) length);
     261        if (rcerrno(vfs_resize, fildes, (aoff64_t) length) != EOK)
     262                return -1;
     263        else
     264                return 0;
    262265}
    263266
  • uspace/srv/vfs/vfs.h

    r79ea5af r67e881c  
    211211extern int vfs_op_read(int fd, aoff64_t, size_t *out_bytes);
    212212extern int vfs_op_rename(int basefd, char *old, char *new);
     213extern int vfs_op_resize(int fd, int64_t size);
    213214extern int vfs_op_stat(int fd);
    214215extern int vfs_op_statfs(int fd);
    215216extern int vfs_op_sync(int fd);
    216 extern int vfs_op_truncate(int fd, int64_t size);
    217217extern int vfs_op_unlink(int parentfd, int expectfd, char *path);
    218218extern int vfs_op_unmount(int mpfd);
  • uspace/srv/vfs/vfs_ipc.c

    r79ea5af r67e881c  
    160160}
    161161
     162static void vfs_in_resize(ipc_callid_t rid, ipc_call_t *request)
     163{
     164        int fd = IPC_GET_ARG1(*request);
     165        int64_t size = MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
     166        int rc = vfs_op_resize(fd, size);
     167        async_answer_0(rid, rc);
     168}
     169
    162170static void vfs_in_stat(ipc_callid_t rid, ipc_call_t *request)
    163171{
     
    179187        int fd = IPC_GET_ARG1(*request);
    180188        int rc = vfs_op_sync(fd);
    181         async_answer_0(rid, rc);
    182 }
    183 
    184 static void vfs_in_truncate(ipc_callid_t rid, ipc_call_t *request)
    185 {
    186         int fd = IPC_GET_ARG1(*request);
    187         int64_t size = MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
    188         int rc = vfs_op_truncate(fd, size);
    189189        async_answer_0(rid, rc);
    190190}
     
    287287                        vfs_in_rename(callid, &call);
    288288                        break;
     289                case VFS_IN_RESIZE:
     290                        vfs_in_resize(callid, &call);
     291                        break;
    289292                case VFS_IN_STAT:
    290293                        vfs_in_stat(callid, &call);
     
    295298                case VFS_IN_SYNC:
    296299                        vfs_in_sync(callid, &call);
    297                         break;
    298                 case VFS_IN_TRUNCATE:
    299                         vfs_in_truncate(callid, &call);
    300300                        break;
    301301                case VFS_IN_UNLINK:
  • uspace/srv/vfs/vfs_ops.c

    r79ea5af r67e881c  
    585585}
    586586
     587int vfs_op_resize(int fd, int64_t size)
     588{
     589        vfs_file_t *file = vfs_file_get(fd);
     590        if (!file)
     591                return EBADF;
     592
     593        fibril_rwlock_write_lock(&file->node->contents_rwlock);
     594       
     595        int rc = vfs_truncate_internal(file->node->fs_handle,
     596            file->node->service_id, file->node->index, size);
     597        if (rc == EOK)
     598                file->node->size = size;
     599       
     600        fibril_rwlock_write_unlock(&file->node->contents_rwlock);
     601        vfs_file_put(file);
     602        return rc;
     603}
     604
    587605int vfs_op_stat(int fd)
    588606{
     
    652670       
    653671        return (int) rc;
    654 }
    655 
    656 int vfs_op_truncate(int fd, int64_t size)
    657 {
    658         vfs_file_t *file = vfs_file_get(fd);
    659         if (!file)
    660                 return EBADF;
    661 
    662         fibril_rwlock_write_lock(&file->node->contents_rwlock);
    663        
    664         int rc = vfs_truncate_internal(file->node->fs_handle,
    665             file->node->service_id, file->node->index, size);
    666         if (rc == EOK)
    667                 file->node->size = size;
    668        
    669         fibril_rwlock_write_unlock(&file->node->contents_rwlock);
    670         vfs_file_put(file);
    671         return rc;
    672672}
    673673
Note: See TracChangeset for help on using the changeset viewer.