Ignore:
File:
1 edited

Legend:

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

    r8e3498b r39330200  
    8686 * and consume system resources.
    8787 *
    88  * Functions that return int return an error code on error and do not
     88 * Functions that return errno_t 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  *      int rc = vfs_open(file, MODE_READ);
     99 *      errno_t rc = vfs_open(file, MODE_READ);
    100100 *      if (rc != EOK) {
    101101 *              (void) vfs_put(file);
     
    128128static int root_fd = -1;
    129129
    130 static int get_parent_and_child(const char *path, char **child)
     130static errno_t get_parent_and_child(const char *path, int *parent, char **child)
    131131{
    132132        size_t size;
     
    136136
    137137        char *slash = str_rchr(apath, L'/');
    138         int parent;
    139138        if (slash == apath) {
    140                 parent = vfs_root();
     139                *parent = vfs_root();
     140                if (*parent < 0) {
     141                        free(apath);
     142                        return EBADF;
     143                }
    141144                *child = apath;
     145                return EOK;
    142146        } else {
    143147                *slash = '\0';
    144                 parent = vfs_lookup(apath, WALK_DIRECTORY);
    145                 if (parent < 0) {
     148                errno_t rc = vfs_lookup(apath, WALK_DIRECTORY, parent);
     149                if (rc != EOK) {
    146150                        free(apath);
    147                         return parent;
     151                        return rc;
    148152                }
    149153                *slash = '/';
     
    151155                free(apath);
    152156                if (!*child) {
    153                         vfs_put(parent);
     157                        vfs_put(*parent);
    154158                        return ENOMEM;
    155159                }
    156         }
    157 
    158         return parent;
     160
     161                return rc;
     162        }
     163
    159164}
    160165
     
    231236 *                      handle will be allocated from high indices
    232237 *
    233  * @return              New file handle on success or a negative error code
    234  */
    235 int vfs_clone(int file_from, int file_to, bool high)
    236 {
     238 * @return              New file handle on success or an error code
     239 */
     240errno_t vfs_clone(int file_from, int file_to, bool high, int *handle)
     241{
     242        assert(handle != NULL);
     243
    237244        async_exch_t *vfs_exch = vfs_exchange_begin();
    238         int rc = async_req_3_0(vfs_exch, VFS_IN_CLONE, (sysarg_t) file_from,
    239             (sysarg_t) file_to, (sysarg_t) high);
     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);
    240248        vfs_exchange_end(vfs_exch);
     249
     250        if (rc == EOK) {
     251                *handle = ret;
     252        }
    241253        return rc;
    242254}
     
    247259 * @param size          Size of @a buf
    248260 *
    249  * @return              EOK on success or a non-negative error code
    250  */
    251 int vfs_cwd_get(char *buf, size_t size)
     261 * @return              EOK on success or a non-error code
     262 */
     263errno_t vfs_cwd_get(char *buf, size_t size)
    252264{
    253265        fibril_mutex_lock(&cwd_mutex);
     
    268280 * @param path  Path of the new working directory
    269281 *
    270  * @return      EOK on success or a negative error code
    271  */
    272 int vfs_cwd_set(const char *path)
     282 * @return      EOK on success or an error code
     283 */
     284errno_t vfs_cwd_set(const char *path)
    273285{
    274286        size_t abs_size;
     
    277289                return ENOMEM;
    278290       
    279         int fd = vfs_lookup(abs, WALK_DIRECTORY);
    280         if (fd < 0) {
     291        int fd;
     292        errno_t rc = vfs_lookup(abs, WALK_DIRECTORY, &fd);
     293        if (rc != EOK) {
    281294                free(abs);
    282                 return fd;
     295                return rc;
    283296        }
    284297       
     
    339352async_sess_t *vfs_fd_session(int file, iface_t iface)
    340353{
    341         struct stat stat;
    342         int rc = vfs_stat(file, &stat);
    343         if (rc != 0)
     354        vfs_stat_t stat;
     355        errno_t rc = vfs_stat(file, &stat);
     356        if (rc != EOK)
    344357                return NULL;
    345358       
     
    357370 * @param info    Place to store volume identification information
    358371 *
    359  * @return                      EOK on success or a negative error code
    360  */
    361 int vfs_fsprobe(const char *fs_name, service_id_t serv,
     372 * @return                      EOK on success or an error code
     373 */
     374errno_t vfs_fsprobe(const char *fs_name, service_id_t serv,
    362375    vfs_fs_probe_info_t *info)
    363376{
    364         sysarg_t rc;
     377        errno_t rc;
    365378       
    366379        ipc_call_t answer;
     
    391404 *        fstypes->fstypes[0..]. To free the list use vfs_fstypes_free().
    392405 *
    393  * @return                      EOK on success or a negative error code
    394  */
    395 int vfs_fstypes(vfs_fstypes_t *fstypes)
     406 * @return                      EOK on success or an error code
     407 */
     408errno_t vfs_fstypes(vfs_fstypes_t *fstypes)
    396409{
    397410        sysarg_t size;
     
    401414
    402415        async_exch_t *exch = vfs_exchange_begin();
    403         int rc = async_req_0_1(exch, VFS_IN_FSTYPES, &size);
     416        errno_t rc = async_req_0_1(exch, VFS_IN_FSTYPES, &size);
    404417
    405418        if (rc != EOK) {
     
    486499 * @param[out] linkedfd If not NULL, will receive a file handle to the linked
    487500 *                      child
    488  * @return              EOK on success or a negative error code
    489  */
    490 int vfs_link(int parent, const char *child, vfs_file_kind_t kind, int *linkedfd)
     501 * @return              EOK on success or an error code
     502 */
     503errno_t vfs_link(int parent, const char *child, vfs_file_kind_t kind, int *linkedfd)
    491504{
    492505        int flags = (kind == KIND_DIRECTORY) ? WALK_DIRECTORY : WALK_REGULAR;
    493         int file = vfs_walk(parent, child, WALK_MUST_CREATE | flags);
    494 
    495         if (file < 0)
    496                 return file;
     506        int file = -1;
     507        errno_t rc = vfs_walk(parent, child, WALK_MUST_CREATE | flags, &file);
     508        if (rc != EOK)
     509                return rc;
    497510
    498511        if (linkedfd)
     
    516529 * @param[out] linkedfd If not NULL, will receive a file handle to the linked
    517530 *                      child
    518  * @return              EOK on success or a negative error code
    519  */
    520 int vfs_link_path(const char *path, vfs_file_kind_t kind, int *linkedfd)
     531 * @return              EOK on success or an error code
     532 */
     533errno_t vfs_link_path(const char *path, vfs_file_kind_t kind, int *linkedfd)
    521534{
    522535        char *child;
    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);
     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);
    528542
    529543        free(child);
    530544        vfs_put(parent);
    531545        return rc;
    532 }       
     546}
    533547
    534548/** Lookup a path relative to the local root
     
    536550 * @param path  Path to be looked up
    537551 * @param flags Walk flags
    538  *
    539  * @return      File handle representing the result on success or a negative
    540  *              error code on error
    541  */
    542 int vfs_lookup(const char *path, int 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 */
     556errno_t vfs_lookup(const char *path, int flags, int *handle)
    543557{
    544558        size_t size;
     
    546560        if (!p)
    547561                return ENOMEM;
     562
    548563        int root = vfs_root();
    549564        if (root < 0) {
     
    551566                return ENOENT;
    552567        }
    553         int rc = vfs_walk(root, p, flags);
     568
     569        // XXX: Workaround for GCC diagnostics.
     570        *handle = -1;
     571
     572        errno_t rc = vfs_walk(root, p, flags, handle);
    554573        vfs_put(root);
    555574        free(p);
     
    564583 * @param flags Walk flags
    565584 * @param mode  Mode in which to open file in
    566  *
    567  * @return      EOK on success or a negative error code
    568  */
    569 int 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);
     585 * @param[out] handle Pointer to variable where handle is to be written.
     586 *
     587 * @return      EOK on success or an error code
     588 */
     589errno_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);
    576597        if (rc != EOK) {
    577598                vfs_put(file);
    578599                return rc;
    579600        }
    580        
    581         return file;
     601
     602        *handle = file;
     603        return EOK;
    582604}
    583605
     
    592614 * @param[out] mountedfd        File handle of the mounted root if not NULL
    593615 *
    594  * @return                      EOK on success or a negative error code
    595  */
    596 int vfs_mount(int mp, const char *fs_name, service_id_t serv, const char *opts,
     616 * @return                      EOK on success or an error code
     617 */
     618errno_t vfs_mount(int mp, const char *fs_name, service_id_t serv, const char *opts,
    597619    unsigned int flags, unsigned int instance, int *mountedfd)
    598620{
    599         sysarg_t rc, rc1;
     621        errno_t rc, rc1;
    600622       
    601623        if (!mountedfd)
     
    636658 * @param[in] instance          Instance number of the file system server
    637659 *
    638  * @return                      EOK on success or a negative error code
    639  */
    640 int vfs_mount_path(const char *mp, const char *fs_name, const char *fqsn,
     660 * @return                      EOK on success or an error code
     661 */
     662errno_t vfs_mount_path(const char *mp, const char *fs_name, const char *fqsn,
    641663    const char *opts, unsigned int flags, unsigned int instance)
    642664{
     
    663685       
    664686        service_id_t service_id;
    665         int res = loc_service_get_id(fqsn, &service_id, flags);
     687        errno_t res = loc_service_get_id(fqsn, &service_id, flags);
    666688        if (res != EOK) {
    667689                if (null_id != -1)
     
    682704        fibril_mutex_lock(&root_mutex);
    683705       
    684         int rc;
     706        errno_t rc;
    685707       
    686708        if (str_cmp(mpa, "/") == 0) {
     
    707729                }
    708730               
    709                 int mpfd = vfs_walk(root_fd, mpa, WALK_DIRECTORY);
    710                 if (mpfd >= 0) {
     731                int mpfd;
     732                rc = vfs_walk(root_fd, mpa, WALK_DIRECTORY, &mpfd);
     733                if (rc == EOK) {
    711734                        rc = vfs_mount(mpfd, fs_name, service_id, opts, flags,
    712735                            instance, NULL);
    713736                        vfs_put(mpfd);
    714                 } else {
    715                         rc = mpfd;
    716737                }
    717738        }
     
    722743                loc_null_destroy(null_id);
    723744       
    724         return (int) rc;
     745        return (errno_t) rc;
    725746}
    726747
     
    731752 * @param mode  Mode in which to open file in
    732753 *
    733  * @return      EOK on success or a negative error code
    734  */
    735 int 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);
     754 * @return      EOK on success or an error code
     755 */
     756errno_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);
    739760        vfs_exchange_end(exch);
    740761       
     
    748769 * @param exch          Exchange to the acceptor
    749770 *
    750  * @return              EOK on success or a negative error code
    751  */
    752 int vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch)
     771 * @return              EOK on success or an error code
     772 */
     773errno_t vfs_pass_handle(async_exch_t *vfs_exch, int file, async_exch_t *exch)
    753774{
    754775        return async_state_change_start(exch, VFS_PASS_HANDLE, (sysarg_t) file,
     
    760781 * @param file  File handle to put
    761782 *
    762  * @return      EOK on success or a negative error code
    763  */
    764 int 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);
     783 * @return      EOK on success or an error code
     784 */
     785errno_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);
    768789        vfs_exchange_end(exch);
    769790       
     
    775796 * @param high   If true, the received file handle will be allocated from high
    776797 *               indices
    777  *
    778  * @return       EOK on success or a negative error code
    779  */
    780 int vfs_receive_handle(bool high)
     798 * @param[out] handle  Received handle.
     799 *
     800 * @return       EOK on success or an error code
     801 */
     802errno_t vfs_receive_handle(bool high, int *handle)
    781803{
    782804        ipc_callid_t callid;
     
    791813
    792814        sysarg_t ret;
    793         sysarg_t rc = async_req_1_1(vfs_exch, VFS_IN_WAIT_HANDLE, high, &ret);
     815        errno_t rc = async_req_1_1(vfs_exch, VFS_IN_WAIT_HANDLE, high, &ret);
    794816
    795817        async_exchange_end(vfs_exch);
    796818
    797         if (rc != EOK)
    798                 return rc;
    799         return ret;
     819        if (rc == EOK) {
     820                *handle = (int) ret;
     821        }
     822
     823        return rc;
    800824}
    801825
     
    815839 * @return              On failure, an error code
    816840 */
    817 int vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte, size_t *nread)
     841errno_t vfs_read(int file, aoff64_t *pos, void *buf, size_t nbyte, size_t *nread)
    818842{
    819843        ssize_t cnt = 0;
    820844        size_t nr = 0;
    821845        uint8_t *bp = (uint8_t *) buf;
    822         int rc;
     846        errno_t rc;
    823847       
    824848        do {
     
    853877 * @param[out] nread    Actual number of bytes read (0 or more)
    854878 *
    855  * @return              EOK on success or a negative error code
    856  */
    857 int vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte,
     879 * @return              EOK on success or an error code
     880 */
     881errno_t vfs_read_short(int file, aoff64_t pos, void *buf, size_t nbyte,
    858882    ssize_t *nread)
    859883{
    860         sysarg_t rc;
     884        errno_t rc;
    861885        ipc_call_t answer;
    862886        aid_t req;
     
    895919 * @param new   New path
    896920 *
    897  * @return      EOK on success or a negative error code
    898  */
    899 int vfs_rename_path(const char *old, const char *new)
    900 {
    901         sysarg_t rc;
    902         sysarg_t rc_orig;
     921 * @return      EOK on success or an error code
     922 */
     923errno_t vfs_rename_path(const char *old, const char *new)
     924{
     925        errno_t rc;
     926        errno_t rc_orig;
    903927        aid_t req;
    904928       
     
    962986 * @param length        New length
    963987 *
    964  * @return              EOK on success or a negative error code
    965  */
    966 int 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),
     988 * @return              EOK on success or an error code
     989 */
     990errno_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),
    970994            UPPER32(length));
    971995        vfs_exchange_end(exch);
     
    9761000/** Return a new file handle representing the local root
    9771001 *
    978  * @return      A clone of the local root file handle or a negative error code
     1002 * @return      A clone of the local root file handle or -1
    9791003 */
    9801004int vfs_root(void)
    9811005{
    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);
     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        }
    9881016        fibril_mutex_unlock(&root_mutex);
    989         return r;
     1017        return fd;
    9901018}
    9911019
     
    9971025 *
    9981026 * @param nroot The new local root file handle
    999  */
    1000 void vfs_root_set(int nroot)
    1001 {
     1027 *
     1028 * @return  Error code
     1029 */
     1030errno_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
    10021038        fibril_mutex_lock(&root_mutex);
    10031039        if (root_fd >= 0)
    10041040                vfs_put(root_fd);
    1005         root_fd = vfs_clone(nroot, -1, true);
     1041        root_fd = new_root;
    10061042        fibril_mutex_unlock(&root_mutex);
     1043
     1044        return EOK;
    10071045}
    10081046
     
    10121050 * @param[out] stat     Place to store file information
    10131051 *
    1014  * @return              EOK on success or a negative error code
    1015  */
    1016 int vfs_stat(int file, struct stat *stat)
    1017 {
    1018         sysarg_t rc;
     1052 * @return              EOK on success or an error code
     1053 */
     1054errno_t vfs_stat(int file, vfs_stat_t *stat)
     1055{
     1056        errno_t rc;
    10191057        aid_t req;
    10201058       
     
    10221060       
    10231061        req = async_send_1(exch, VFS_IN_STAT, file, NULL);
    1024         rc = async_data_read_start(exch, (void *) stat, sizeof(struct stat));
     1062        rc = async_data_read_start(exch, (void *) stat, sizeof(vfs_stat_t));
    10251063        if (rc != EOK) {
    10261064                vfs_exchange_end(exch);
    10271065               
    1028                 sysarg_t rc_orig;
     1066                errno_t rc_orig;
    10291067                async_wait_for(req, &rc_orig);
    10301068               
     
    10461084 * @param[out] stat     Place to store file information
    10471085 *
    1048  * @return              EOK on success or a negative error code
    1049  */
    1050 int 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);
     1086 * @return              EOK on success or an error code
     1087 */
     1088errno_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);
    10571096
    10581097        vfs_put(file);
     
    10661105 * @param[out] st       Buffer for storing information
    10671106 *
    1068  * @return              EOK on success or a negative error code
    1069  */
    1070 int vfs_statfs(int file, struct statfs *st)
    1071 {
    1072         sysarg_t rc, ret;
     1107 * @return              EOK on success or an error code
     1108 */
     1109errno_t vfs_statfs(int file, vfs_statfs_t *st)
     1110{
     1111        errno_t rc, ret;
    10731112        aid_t req;
    10741113
     
    10911130 * @param[out] st       Buffer for storing information
    10921131 *
    1093  * @return              EOK on success or a negative error code
    1094  */
    1095 int 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);
     1132 * @return              EOK on success or an error code
     1133 */
     1134errno_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);
    11021142
    11031143        vfs_put(file);
     
    11101150 * @param file  File handle to synchronize
    11111151 *
    1112  * @return      EOK on success or a negative error code
    1113  */
    1114 int 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);
     1152 * @return      EOK on success or an error code
     1153 */
     1154errno_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);
    11181158        vfs_exchange_end(exch);
    11191159       
     
    11321172 * @param expect        File handle of the unlinked child
    11331173 *
    1134  * @return              EOK on success or a negative error code
    1135  */
    1136 int vfs_unlink(int parent, const char *child, int expect)
    1137 {
    1138         sysarg_t rc;
     1174 * @return              EOK on success or an error code
     1175 */
     1176errno_t vfs_unlink(int parent, const char *child, int expect)
     1177{
     1178        errno_t rc;
    11391179        aid_t req;
    11401180       
     
    11461186        vfs_exchange_end(exch);
    11471187       
    1148         sysarg_t rc_orig;
     1188        errno_t rc_orig;
    11491189        async_wait_for(req, &rc_orig);
    11501190       
    11511191        if (rc_orig != EOK)
    1152                 return (int) rc_orig;
     1192                return (errno_t) rc_orig;
    11531193        return rc;
    11541194}
     
    11611201 * @param path          Old path to be unlinked
    11621202 *
    1163  * @return              EOK on success or a negative error code
    1164  */
    1165 int vfs_unlink_path(const char *path)
    1166 {
    1167         int expect = vfs_lookup(path, 0);
    1168         if (expect < 0)
    1169                 return expect;
     1203 * @return              EOK on success or an error code
     1204 */
     1205errno_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;
    11701211
    11711212        char *child;
    1172         int parent = get_parent_and_child(path, &child);
    1173         if (parent < 0) {
     1213        int parent;
     1214        rc = get_parent_and_child(path, &parent, &child);
     1215        if (rc != EOK) {
    11741216                vfs_put(expect);
    1175                 return parent;
    1176         }
    1177 
    1178         int rc = vfs_unlink(parent, child, expect);
     1217                return rc;
     1218        }
     1219
     1220        rc = vfs_unlink(parent, child, expect);
    11791221       
    11801222        free(child);
     
    11881230 * @param mp    File handle representing the mount-point
    11891231 *
    1190  * @return      EOK on success or a negative error code
    1191  */
    1192 int 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);
     1232 * @return      EOK on success or an error code
     1233 */
     1234errno_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);
    11961238        vfs_exchange_end(exch);
    11971239        return rc;
     
    12021244 * @param mpp   Mount-point path
    12031245 *
    1204  * @return      EOK on success or a negative error code
    1205  */
    1206 int 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);
     1246 * @return      EOK on success or an error code
     1247 */
     1248errno_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);
    12131256        vfs_put(mp);
    12141257        return rc;
     
    12201263 * @param path          Parent-relative path to be walked
    12211264 * @param flags         Flags influencing the walk
    1222  *
    1223  * @retrun              File handle representing the result on success or
    1224  *                      a negative error code on error
    1225  */
    1226 int vfs_walk(int parent, const char *path, int flags)
     1265 * @param[out] handle   File handle representing the result on success.
     1266 *
     1267 * @return              Error code.
     1268 */
     1269errno_t vfs_walk(int parent, const char *path, int flags, int *handle)
    12271270{
    12281271        async_exch_t *exch = vfs_exchange_begin();
     
    12301273        ipc_call_t answer;
    12311274        aid_t req = async_send_2(exch, VFS_IN_WALK, parent, flags, &answer);
    1232         sysarg_t rc = async_data_write_start(exch, path, str_size(path));
     1275        errno_t rc = async_data_write_start(exch, path, str_size(path));
    12331276        vfs_exchange_end(exch);
    12341277               
    1235         sysarg_t rc_orig;
     1278        errno_t rc_orig;
    12361279        async_wait_for(req, &rc_orig);
    12371280
    12381281        if (rc_orig != EOK)
    1239                 return (int) rc_orig;
     1282                return (errno_t) rc_orig;
    12401283               
    12411284        if (rc != EOK)
    1242                 return (int) rc;
    1243        
    1244         return (int) IPC_GET_ARG1(answer);
     1285                return (errno_t) rc;
     1286       
     1287        *handle = (int) IPC_GET_ARG1(answer);
     1288        return EOK;
    12451289}
    12461290
     
    12601304 * @return              On failure, an error code
    12611305 */
    1262 int vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte,
     1306errno_t vfs_write(int file, aoff64_t *pos, const void *buf, size_t nbyte,
    12631307    size_t *nwritten)
    12641308{
     
    12661310        ssize_t nwr = 0;
    12671311        const uint8_t *bp = (uint8_t *) buf;
    1268         int rc;
     1312        errno_t rc;
    12691313
    12701314        do {
     
    12971341 * @param[out] nread    Actual number of bytes written (0 or more)
    12981342 *
    1299  * @return              EOK on success or a negative error code
    1300  */
    1301 int vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte,
     1343 * @return              EOK on success or an error code
     1344 */
     1345errno_t vfs_write_short(int file, aoff64_t pos, const void *buf, size_t nbyte,
    13021346    ssize_t *nwritten)
    13031347{
    1304         sysarg_t rc;
     1348        errno_t rc;
    13051349        ipc_call_t answer;
    13061350        aid_t req;
Note: See TracChangeset for help on using the changeset viewer.