Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vfs/vfs.c

    r39330200 r8e3498b  
    8686 * and consume system resources.
    8787 *
    88  * Functions that return errno_t return an error code on error and do not
     88 * Functions that return int return an error code on error and do not
    8989 * set errno. Depending on function, success is signalled by returning either
    9090 * EOK or a non-negative file handle.
     
    9797 *      if (file < 0)
    9898 *              return file;
    99  *      errno_t rc = vfs_open(file, MODE_READ);
     99 *      int rc = vfs_open(file, MODE_READ);
    100100 *      if (rc != EOK) {
    101101 *              (void) vfs_put(file);
     
    128128static int root_fd = -1;
    129129
    130 static errno_t get_parent_and_child(const char *path, int *parent, char **child)
     130static int get_parent_and_child(const char *path, char **child)
    131131{
    132132        size_t size;
     
    136136
    137137        char *slash = str_rchr(apath, L'/');
     138        int parent;
    138139        if (slash == apath) {
    139                 *parent = vfs_root();
    140                 if (*parent < 0) {
    141                         free(apath);
    142                         return EBADF;
    143                 }
     140                parent = vfs_root();
    144141                *child = apath;
    145                 return EOK;
    146142        } else {
    147143                *slash = '\0';
    148                 errno_t rc = vfs_lookup(apath, WALK_DIRECTORY, parent);
    149                 if (rc != EOK) {
     144                parent = vfs_lookup(apath, WALK_DIRECTORY);
     145                if (parent < 0) {
    150146                        free(apath);
    151                         return rc;
     147                        return parent;
    152148                }
    153149                *slash = '/';
     
    155151                free(apath);
    156152                if (!*child) {
    157                         vfs_put(*parent);
     153                        vfs_put(parent);
    158154                        return ENOMEM;
    159155                }
    160 
    161                 return rc;
    162         }
    163 
     156        }
     157
     158        return parent;
    164159}
    165160
     
    236231 *                      handle will be allocated from high indices
    237232 *
    238  * @return              New file handle on success or an error code
    239  */
    240 errno_t vfs_clone(int file_from, int file_to, bool high, int *handle)
    241 {
    242         assert(handle != NULL);
    243 
     233 * @return              New file handle on success or a negative error code
     234 */
     235int vfs_clone(int file_from, int file_to, bool high)
     236{
    244237        async_exch_t *vfs_exch = vfs_exchange_begin();
    245         sysarg_t ret;
    246         errno_t rc = async_req_3_1(vfs_exch, VFS_IN_CLONE, (sysarg_t) file_from,
    247             (sysarg_t) file_to, (sysarg_t) high, &ret);
     238        int rc = async_req_3_0(vfs_exch, VFS_IN_CLONE, (sysarg_t) file_from,
     239            (sysarg_t) file_to, (sysarg_t) high);
    248240        vfs_exchange_end(vfs_exch);
    249 
    250         if (rc == EOK) {
    251                 *handle = ret;
    252         }
    253241        return rc;
    254242}
     
    259247 * @param size          Size of @a buf
    260248 *
    261  * @return              EOK on success or a non-error code
    262  */
    263 errno_t vfs_cwd_get(char *buf, size_t size)
     249 * @return              EOK on success or a non-negative error code
     250 */
     251int vfs_cwd_get(char *buf, size_t size)
    264252{
    265253        fibril_mutex_lock(&cwd_mutex);
     
    280268 * @param path  Path of the new working directory
    281269 *
    282  * @return      EOK on success or an error code
    283  */
    284 errno_t vfs_cwd_set(const char *path)
     270 * @return      EOK on success or a negative error code
     271 */
     272int vfs_cwd_set(const char *path)
    285273{
    286274        size_t abs_size;
     
    289277                return ENOMEM;
    290278       
    291         int fd;
    292         errno_t rc = vfs_lookup(abs, WALK_DIRECTORY, &fd);
    293         if (rc != EOK) {
     279        int fd = vfs_lookup(abs, WALK_DIRECTORY);
     280        if (fd < 0) {
    294281                free(abs);
    295                 return rc;
     282                return fd;
    296283        }
    297284       
     
    352339async_sess_t *vfs_fd_session(int file, iface_t iface)
    353340{
    354         vfs_stat_t stat;
    355         errno_t rc = vfs_stat(file, &stat);
    356         if (rc != EOK)
     341        struct stat stat;
     342        int rc = vfs_stat(file, &stat);
     343        if (rc != 0)
    357344                return NULL;
    358345       
     
    370357 * @param info    Place to store volume identification information
    371358 *
    372  * @return                      EOK on success or an error code
    373  */
    374 errno_t vfs_fsprobe(const char *fs_name, service_id_t serv,
     359 * @return                      EOK on success or a negative error code
     360 */
     361int vfs_fsprobe(const char *fs_name, service_id_t serv,
    375362    vfs_fs_probe_info_t *info)
    376363{
    377         errno_t rc;
     364        sysarg_t rc;
    378365       
    379366        ipc_call_t answer;
     
    404391 *        fstypes->fstypes[0..]. To free the list use vfs_fstypes_free().
    405392 *
    406  * @return                      EOK on success or an error code
    407  */
    408 errno_t vfs_fstypes(vfs_fstypes_t *fstypes)
     393 * @return                      EOK on success or a negative error code
     394 */
     395int vfs_fstypes(vfs_fstypes_t *fstypes)
    409396{
    410397        sysarg_t size;
     
    414401
    415402        async_exch_t *exch = vfs_exchange_begin();
    416         errno_t rc = async_req_0_1(exch, VFS_IN_FSTYPES, &size);
     403        int rc = async_req_0_1(exch, VFS_IN_FSTYPES, &size);
    417404
    418405        if (rc != EOK) {
     
    499486 * @param[out] linkedfd If not NULL, will receive a file handle to the linked
    500487 *                      child
    501  * @return              EOK on success or an error code
    502  */
    503 errno_t vfs_link(int parent, const char *child, vfs_file_kind_t kind, int *linkedfd)
     488 * @return              EOK on success or a negative error code
     489 */
     490int vfs_link(int parent, const char *child, vfs_file_kind_t kind, int *linkedfd)
    504491{
    505492        int flags = (kind == KIND_DIRECTORY) ? WALK_DIRECTORY : WALK_REGULAR;
    506         int file = -1;
    507         errno_t rc = vfs_walk(parent, child, WALK_MUST_CREATE | flags, &file);
    508         if (rc != EOK)
    509                 return rc;
     493        int file = vfs_walk(parent, child, WALK_MUST_CREATE | flags);
     494
     495        if (file < 0)
     496                return file;
    510497
    511498        if (linkedfd)
     
    529516 * @param[out] linkedfd If not NULL, will receive a file handle to the linked
    530517 *                      child
    531  * @return              EOK on success or an error code
    532  */
    533 errno_t vfs_link_path(const char *path, vfs_file_kind_t kind, int *linkedfd)
     518 * @return              EOK on success or a negative error code
     519 */
     520int vfs_link_path(const char *path, vfs_file_kind_t kind, int *linkedfd)
    534521{
    535522        char *child;
    536         int parent;
    537         errno_t rc = get_parent_and_child(path, &parent, &child);
    538         if (rc != EOK)
    539                 return rc;
    540 
    541         rc = vfs_link(parent, child, kind, linkedfd);
     523        int parent = get_parent_and_child(path, &child);
     524        if (parent < 0)
     525                return parent;
     526
     527        int rc = vfs_link(parent, child, kind, linkedfd);
    542528
    543529        free(child);
    544530        vfs_put(parent);
    545531        return rc;
    546 }
     532}       
    547533
    548534/** Lookup a path relative to the local root
     
    550536 * @param path  Path to be looked up
    551537 * @param flags Walk flags
    552  * @param[out] handle Pointer to variable where handle is to be written.
    553  *
    554  * @return      EOK on success or an error code.
    555  */
    556 errno_t vfs_lookup(const char *path, int flags, int *handle)
     538 *
     539 * @return      File handle representing the result on success or a negative
     540 *              error code on error
     541 */
     542int vfs_lookup(const char *path, int flags)
    557543{
    558544        size_t size;
     
    560546        if (!p)
    561547                return ENOMEM;
    562 
    563548        int root = vfs_root();
    564549        if (root < 0) {
     
    566551                return ENOENT;
    567552        }
    568 
    569         // XXX: Workaround for GCC diagnostics.
    570         *handle = -1;
    571 
    572         errno_t rc = vfs_walk(root, p, flags, handle);
     553        int rc = vfs_walk(root, p, flags);
    573554        vfs_put(root);
    574555        free(p);
     
    583564 * @param flags Walk flags
    584565 * @param mode  Mode in which to open file in
    585  * @param[out] handle Pointer to variable where handle is to be written.
    586  *
    587  * @return      EOK on success or an error code
    588  */
    589 errno_t vfs_lookup_open(const char *path, int flags, int mode, int *handle)
    590 {
    591         int file;
    592         errno_t rc = vfs_lookup(path, flags, &file);
    593         if (rc != EOK)
    594                 return rc;
    595 
    596         rc = vfs_open(file, mode);
     566 *
     567 * @return      EOK on success or a negative error code
     568 */
     569int vfs_lookup_open(const char *path, int flags, int mode)
     570{
     571        int file = vfs_lookup(path, flags);
     572        if (file < 0)
     573                return file;
     574
     575        int rc = vfs_open(file, mode);
    597576        if (rc != EOK) {
    598577                vfs_put(file);
    599578                return rc;
    600579        }
    601 
    602         *handle = file;
    603         return EOK;
     580       
     581        return file;
    604582}
    605583
     
    614592 * @param[out] mountedfd        File handle of the mounted root if not NULL
    615593 *
    616  * @return                      EOK on success or an error code
    617  */
    618 errno_t vfs_mount(int mp, const char *fs_name, service_id_t serv, const char *opts,
     594 * @return                      EOK on success or a negative error code
     595 */
     596int vfs_mount(int mp, const char *fs_name, service_id_t serv, const char *opts,
    619597    unsigned int flags, unsigned int instance, int *mountedfd)
    620598{
    621         errno_t rc, rc1;
     599        sysarg_t rc, rc1;
    622600       
    623601        if (!mountedfd)
     
    658636 * @param[in] instance          Instance number of the file system server
    659637 *
    660  * @return                      EOK on success or an error code
    661  */
    662 errno_t vfs_mount_path(const char *mp, const char *fs_name, const char *fqsn,
     638 * @return                      EOK on success or a negative error code
     639 */
     640int vfs_mount_path(const char *mp, const char *fs_name, const char *fqsn,
    663641    const char *opts, unsigned int flags, unsigned int instance)
    664642{
     
    685663       
    686664        service_id_t service_id;
    687         errno_t res = loc_service_get_id(fqsn, &service_id, flags);
     665        int res = loc_service_get_id(fqsn, &service_id, flags);
    688666        if (res != EOK) {
    689667                if (null_id != -1)
     
    704682        fibril_mutex_lock(&root_mutex);
    705683       
    706         errno_t rc;
     684        int rc;
    707685       
    708686        if (str_cmp(mpa, "/") == 0) {
     
    729707                }
    730708               
    731                 int mpfd;
    732                 rc = vfs_walk(root_fd, mpa, WALK_DIRECTORY, &mpfd);
    733                 if (rc == EOK) {
     709                int mpfd = vfs_walk(root_fd, mpa, WALK_DIRECTORY);
     710                if (mpfd >= 0) {
    734711                        rc = vfs_mount(mpfd, fs_name, service_id, opts, flags,
    735712                            instance, NULL);
    736713                        vfs_put(mpfd);
     714                } else {
     715                        rc = mpfd;
    737716                }
    738717        }
     
    743722                loc_null_destroy(null_id);
    744723       
    745         return (errno_t) rc;
     724        return (int) rc;
    746725}
    747726
     
    752731 * @param mode  Mode in which to open file in
    753732 *
    754  * @return      EOK on success or an error code
    755  */
    756 errno_t vfs_open(int file, int mode)
    757 {
    758         async_exch_t *exch = vfs_exchange_begin();
    759         errno_t rc = async_req_2_0(exch, VFS_IN_OPEN, file, mode);
     733 * @return      EOK on success or a negative error code
     734 */
     735int vfs_open(int file, int mode)
     736{
     737        async_exch_t *exch = vfs_exchange_begin();
     738        int rc = async_req_2_0(exch, VFS_IN_OPEN, file, mode);
    760739        vfs_exchange_end(exch);
    761740       
     
    769748 * @param exch          Exchange to the acceptor
    770749 *
    771  * @return              EOK on success or an error code
    772  */
    773 errno_t vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch)
     750 * @return              EOK on success or a negative error code
     751 */
     752int vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch)
    774753{
    775754        return async_state_change_start(exch, VFS_PASS_HANDLE, (sysarg_t) file,
     
    781760 * @param file  File handle to put
    782761 *
    783  * @return      EOK on success or an error code
    784  */
    785 errno_t vfs_put(int file)
    786 {
    787         async_exch_t *exch = vfs_exchange_begin();
    788         errno_t rc = async_req_1_0(exch, VFS_IN_PUT, file);
     762 * @return      EOK on success or a negative error code
     763 */
     764int vfs_put(int file)
     765{
     766        async_exch_t *exch = vfs_exchange_begin();
     767        int rc = async_req_1_0(exch, VFS_IN_PUT, file);
    789768        vfs_exchange_end(exch);
    790769       
     
    796775 * @param high   If true, the received file handle will be allocated from high
    797776 *               indices
    798  * @param[out] handle  Received handle.
    799  *
    800  * @return       EOK on success or an error code
    801  */
    802 errno_t vfs_receive_handle(bool high, int *handle)
     777 *
     778 * @return       EOK on success or a negative error code
     779 */
     780int vfs_receive_handle(bool high)
    803781{
    804782        ipc_callid_t callid;
     
    813791
    814792        sysarg_t ret;
    815         errno_t rc = async_req_1_1(vfs_exch, VFS_IN_WAIT_HANDLE, high, &ret);
     793        sysarg_t rc = async_req_1_1(vfs_exch, VFS_IN_WAIT_HANDLE, high, &ret);
    816794
    817795        async_exchange_end(vfs_exch);
    818796
    819         if (rc == EOK) {
    820                 *handle = (int) ret;
    821         }
    822 
    823         return rc;
     797        if (rc != EOK)
     798                return rc;
     799        return ret;
    824800}
    825801
     
    839815 * @return              On failure, an error code
    840816 */
    841 errno_t vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte, size_t *nread)
     817int vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte, size_t *nread)
    842818{
    843819        ssize_t cnt = 0;
    844820        size_t nr = 0;
    845821        uint8_t *bp = (uint8_t *) buf;
    846         errno_t rc;
     822        int rc;
    847823       
    848824        do {
     
    877853 * @param[out] nread    Actual number of bytes read (0 or more)
    878854 *
    879  * @return              EOK on success or an error code
    880  */
    881 errno_t vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte,
     855 * @return              EOK on success or a negative error code
     856 */
     857int vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte,
    882858    ssize_t *nread)
    883859{
    884         errno_t rc;
     860        sysarg_t rc;
    885861        ipc_call_t answer;
    886862        aid_t req;
     
    919895 * @param new   New path
    920896 *
    921  * @return      EOK on success or an error code
    922  */
    923 errno_t vfs_rename_path(const char *old, const char *new)
    924 {
    925         errno_t rc;
    926         errno_t rc_orig;
     897 * @return      EOK on success or a negative error code
     898 */
     899int vfs_rename_path(const char *old, const char *new)
     900{
     901        sysarg_t rc;
     902        sysarg_t rc_orig;
    927903        aid_t req;
    928904       
     
    986962 * @param length        New length
    987963 *
    988  * @return              EOK on success or an error code
    989  */
    990 errno_t vfs_resize(int file, aoff64_t length)
    991 {
    992         async_exch_t *exch = vfs_exchange_begin();
    993         errno_t rc = async_req_3_0(exch, VFS_IN_RESIZE, file, LOWER32(length),
     964 * @return              EOK on success or a negative error code
     965 */
     966int vfs_resize(int file, aoff64_t length)
     967{
     968        async_exch_t *exch = vfs_exchange_begin();
     969        int rc = async_req_3_0(exch, VFS_IN_RESIZE, file, LOWER32(length),
    994970            UPPER32(length));
    995971        vfs_exchange_end(exch);
     
    1000976/** Return a new file handle representing the local root
    1001977 *
    1002  * @return      A clone of the local root file handle or -1
     978 * @return      A clone of the local root file handle or a negative error code
    1003979 */
    1004980int vfs_root(void)
    1005981{
    1006         fibril_mutex_lock(&root_mutex);
    1007         int fd;
    1008         if (root_fd < 0) {
    1009                 fd = -1;
    1010         } else {
    1011                 errno_t rc = vfs_clone(root_fd, -1, true, &fd);
    1012                 if (rc != EOK) {
    1013                         fd = -1;
    1014                 }
    1015         }
     982        fibril_mutex_lock(&root_mutex);
     983        int r;
     984        if (root_fd < 0)
     985                r = ENOENT;
     986        else
     987                r = vfs_clone(root_fd, -1, true);
    1016988        fibril_mutex_unlock(&root_mutex);
    1017         return fd;
     989        return r;
    1018990}
    1019991
     
    1025997 *
    1026998 * @param nroot The new local root file handle
    1027  *
    1028  * @return  Error code
    1029  */
    1030 errno_t vfs_root_set(int nroot)
    1031 {
    1032         int new_root;
    1033         errno_t rc = vfs_clone(nroot, -1, true, &new_root);
    1034         if (rc != EOK) {
    1035                 return rc;
    1036         }
    1037 
     999 */
     1000void vfs_root_set(int nroot)
     1001{
    10381002        fibril_mutex_lock(&root_mutex);
    10391003        if (root_fd >= 0)
    10401004                vfs_put(root_fd);
    1041         root_fd = new_root;
     1005        root_fd = vfs_clone(nroot, -1, true);
    10421006        fibril_mutex_unlock(&root_mutex);
    1043 
    1044         return EOK;
    10451007}
    10461008
     
    10501012 * @param[out] stat     Place to store file information
    10511013 *
    1052  * @return              EOK on success or an error code
    1053  */
    1054 errno_t vfs_stat(int file, vfs_stat_t *stat)
    1055 {
    1056         errno_t rc;
     1014 * @return              EOK on success or a negative error code
     1015 */
     1016int vfs_stat(int file, struct stat *stat)
     1017{
     1018        sysarg_t rc;
    10571019        aid_t req;
    10581020       
     
    10601022       
    10611023        req = async_send_1(exch, VFS_IN_STAT, file, NULL);
    1062         rc = async_data_read_start(exch, (void *) stat, sizeof(vfs_stat_t));
     1024        rc = async_data_read_start(exch, (void *) stat, sizeof(struct stat));
    10631025        if (rc != EOK) {
    10641026                vfs_exchange_end(exch);
    10651027               
    1066                 errno_t rc_orig;
     1028                sysarg_t rc_orig;
    10671029                async_wait_for(req, &rc_orig);
    10681030               
     
    10841046 * @param[out] stat     Place to store file information
    10851047 *
    1086  * @return              EOK on success or an error code
    1087  */
    1088 errno_t vfs_stat_path(const char *path, vfs_stat_t *stat)
    1089 {
    1090         int file;
    1091         errno_t rc = vfs_lookup(path, 0, &file);
    1092         if (rc != EOK)
    1093                 return rc;
    1094        
    1095         rc = vfs_stat(file, stat);
     1048 * @return              EOK on success or a negative error code
     1049 */
     1050int vfs_stat_path(const char *path, struct stat *stat)
     1051{
     1052        int file = vfs_lookup(path, 0);
     1053        if (file < 0)
     1054                return file;
     1055       
     1056        int rc = vfs_stat(file, stat);
    10961057
    10971058        vfs_put(file);
     
    11051066 * @param[out] st       Buffer for storing information
    11061067 *
    1107  * @return              EOK on success or an error code
    1108  */
    1109 errno_t vfs_statfs(int file, vfs_statfs_t *st)
    1110 {
    1111         errno_t rc, ret;
     1068 * @return              EOK on success or a negative error code
     1069 */
     1070int vfs_statfs(int file, struct statfs *st)
     1071{
     1072        sysarg_t rc, ret;
    11121073        aid_t req;
    11131074
     
    11301091 * @param[out] st       Buffer for storing information
    11311092 *
    1132  * @return              EOK on success or an error code
    1133  */
    1134 errno_t vfs_statfs_path(const char *path, vfs_statfs_t *st)
    1135 {
    1136         int file;
    1137         errno_t rc = vfs_lookup(path, 0, &file);
    1138         if (rc != EOK)
    1139                 return rc;
    1140        
    1141         rc = vfs_statfs(file, st);
     1093 * @return              EOK on success or a negative error code
     1094 */
     1095int vfs_statfs_path(const char *path, struct statfs *st)
     1096{
     1097        int file = vfs_lookup(path, 0);
     1098        if (file < 0)
     1099                return file;
     1100       
     1101        int rc = vfs_statfs(file, st);
    11421102
    11431103        vfs_put(file);
     
    11501110 * @param file  File handle to synchronize
    11511111 *
    1152  * @return      EOK on success or an error code
    1153  */
    1154 errno_t vfs_sync(int file)
    1155 {
    1156         async_exch_t *exch = vfs_exchange_begin();
    1157         errno_t rc = async_req_1_0(exch, VFS_IN_SYNC, file);
     1112 * @return      EOK on success or a negative error code
     1113 */
     1114int vfs_sync(int file)
     1115{
     1116        async_exch_t *exch = vfs_exchange_begin();
     1117        int rc = async_req_1_0(exch, VFS_IN_SYNC, file);
    11581118        vfs_exchange_end(exch);
    11591119       
     
    11721132 * @param expect        File handle of the unlinked child
    11731133 *
    1174  * @return              EOK on success or an error code
    1175  */
    1176 errno_t vfs_unlink(int parent, const char *child, int expect)
    1177 {
    1178         errno_t rc;
     1134 * @return              EOK on success or a negative error code
     1135 */
     1136int vfs_unlink(int parent, const char *child, int expect)
     1137{
     1138        sysarg_t rc;
    11791139        aid_t req;
    11801140       
     
    11861146        vfs_exchange_end(exch);
    11871147       
    1188         errno_t rc_orig;
     1148        sysarg_t rc_orig;
    11891149        async_wait_for(req, &rc_orig);
    11901150       
    11911151        if (rc_orig != EOK)
    1192                 return (errno_t) rc_orig;
     1152                return (int) rc_orig;
    11931153        return rc;
    11941154}
     
    12011161 * @param path          Old path to be unlinked
    12021162 *
    1203  * @return              EOK on success or an error code
    1204  */
    1205 errno_t vfs_unlink_path(const char *path)
    1206 {
    1207         int expect;
    1208         errno_t rc = vfs_lookup(path, 0, &expect);
    1209         if (rc != EOK)
    1210                 return rc;
     1163 * @return              EOK on success or a negative error code
     1164 */
     1165int vfs_unlink_path(const char *path)
     1166{
     1167        int expect = vfs_lookup(path, 0);
     1168        if (expect < 0)
     1169                return expect;
    12111170
    12121171        char *child;
    1213         int parent;
    1214         rc = get_parent_and_child(path, &parent, &child);
    1215         if (rc != EOK) {
     1172        int parent = get_parent_and_child(path, &child);
     1173        if (parent < 0) {
    12161174                vfs_put(expect);
    1217                 return rc;
    1218         }
    1219 
    1220         rc = vfs_unlink(parent, child, expect);
     1175                return parent;
     1176        }
     1177
     1178        int rc = vfs_unlink(parent, child, expect);
    12211179       
    12221180        free(child);
     
    12301188 * @param mp    File handle representing the mount-point
    12311189 *
    1232  * @return      EOK on success or an error code
    1233  */
    1234 errno_t vfs_unmount(int mp)
    1235 {
    1236         async_exch_t *exch = vfs_exchange_begin();
    1237         errno_t rc = async_req_1_0(exch, VFS_IN_UNMOUNT, mp);
     1190 * @return      EOK on success or a negative error code
     1191 */
     1192int vfs_unmount(int mp)
     1193{
     1194        async_exch_t *exch = vfs_exchange_begin();
     1195        int rc = async_req_1_0(exch, VFS_IN_UNMOUNT, mp);
    12381196        vfs_exchange_end(exch);
    12391197        return rc;
     
    12441202 * @param mpp   Mount-point path
    12451203 *
    1246  * @return      EOK on success or an error code
    1247  */
    1248 errno_t vfs_unmount_path(const char *mpp)
    1249 {
    1250         int mp;
    1251         errno_t rc = vfs_lookup(mpp, WALK_MOUNT_POINT | WALK_DIRECTORY, &mp);
    1252         if (rc != EOK)
    1253                 return rc;
    1254        
    1255         rc = vfs_unmount(mp);
     1204 * @return      EOK on success or a negative error code
     1205 */
     1206int vfs_unmount_path(const char *mpp)
     1207{
     1208        int mp = vfs_lookup(mpp, WALK_MOUNT_POINT | WALK_DIRECTORY);
     1209        if (mp < 0)
     1210                return mp;
     1211       
     1212        int rc = vfs_unmount(mp);
    12561213        vfs_put(mp);
    12571214        return rc;
     
    12631220 * @param path          Parent-relative path to be walked
    12641221 * @param flags         Flags influencing the walk
    1265  * @param[out] handle   File handle representing the result on success.
    1266  *
    1267  * @return              Error code.
    1268  */
    1269 errno_t vfs_walk(int parent, const char *path, int flags, int *handle)
     1222 *
     1223 * @retrun              File handle representing the result on success or
     1224 *                      a negative error code on error
     1225 */
     1226int vfs_walk(int parent, const char *path, int flags)
    12701227{
    12711228        async_exch_t *exch = vfs_exchange_begin();
     
    12731230        ipc_call_t answer;
    12741231        aid_t req = async_send_2(exch, VFS_IN_WALK, parent, flags, &answer);
    1275         errno_t rc = async_data_write_start(exch, path, str_size(path));
     1232        sysarg_t rc = async_data_write_start(exch, path, str_size(path));
    12761233        vfs_exchange_end(exch);
    12771234               
    1278         errno_t rc_orig;
     1235        sysarg_t rc_orig;
    12791236        async_wait_for(req, &rc_orig);
    12801237
    12811238        if (rc_orig != EOK)
    1282                 return (errno_t) rc_orig;
     1239                return (int) rc_orig;
    12831240               
    12841241        if (rc != EOK)
    1285                 return (errno_t) rc;
    1286        
    1287         *handle = (int) IPC_GET_ARG1(answer);
    1288         return EOK;
     1242                return (int) rc;
     1243       
     1244        return (int) IPC_GET_ARG1(answer);
    12891245}
    12901246
     
    13041260 * @return              On failure, an error code
    13051261 */
    1306 errno_t vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte,
     1262int vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte,
    13071263    size_t *nwritten)
    13081264{
     
    13101266        ssize_t nwr = 0;
    13111267        const uint8_t *bp = (uint8_t *) buf;
    1312         errno_t rc;
     1268        int rc;
    13131269
    13141270        do {
     
    13411297 * @param[out] nread    Actual number of bytes written (0 or more)
    13421298 *
    1343  * @return              EOK on success or an error code
    1344  */
    1345 errno_t vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte,
     1299 * @return              EOK on success or a negative error code
     1300 */
     1301int vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte,
    13461302    ssize_t *nwritten)
    13471303{
    1348         errno_t rc;
     1304        sysarg_t rc;
    13491305        ipc_call_t answer;
    13501306        aid_t req;
Note: See TracChangeset for help on using the changeset viewer.