Ignore:
File:
1 edited

Legend:

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

    ra35b458 r1b20da0  
    264264{
    265265        fibril_mutex_lock(&cwd_mutex);
    266 
     266       
    267267        if ((cwd_size == 0) || (size < cwd_size + 1)) {
    268268                fibril_mutex_unlock(&cwd_mutex);
    269269                return ERANGE;
    270270        }
    271 
     271       
    272272        str_cpy(buf, size, cwd_path);
    273273        fibril_mutex_unlock(&cwd_mutex);
    274 
     274       
    275275        return EOK;
    276276}
     
    288288        if (!abs)
    289289                return ENOMEM;
    290 
     290       
    291291        int fd;
    292292        errno_t rc = vfs_lookup(abs, WALK_DIRECTORY, &fd);
     
    295295                return rc;
    296296        }
    297 
     297       
    298298        fibril_mutex_lock(&cwd_mutex);
    299 
     299       
    300300        if (cwd_fd >= 0)
    301301                vfs_put(cwd_fd);
    302 
     302       
    303303        if (cwd_path)
    304304                free(cwd_path);
    305 
     305       
    306306        cwd_fd = fd;
    307307        cwd_path = abs;
    308308        cwd_size = abs_size;
    309 
     309       
    310310        fibril_mutex_unlock(&cwd_mutex);
    311311        return EOK;
     
    319319{
    320320        fibril_mutex_lock(&vfs_mutex);
    321 
     321       
    322322        while (vfs_sess == NULL) {
    323323                vfs_sess = service_connect_blocking(SERVICE_VFS, INTERFACE_VFS,
    324324                    0);
    325325        }
    326 
     326       
    327327        fibril_mutex_unlock(&vfs_mutex);
    328 
     328       
    329329        return async_exchange_begin(vfs_sess);
    330330}
     
    356356        if (rc != EOK)
    357357                return NULL;
    358 
     358       
    359359        if (stat.service == 0)
    360360                return NULL;
    361 
     361       
    362362        return loc_service_connect(stat.service, iface, 0);
    363363}
     
    376376{
    377377        errno_t rc;
    378 
     378       
    379379        ipc_call_t answer;
    380380        async_exch_t *exch = vfs_exchange_begin();
    381381        aid_t req = async_send_1(exch, VFS_IN_FSPROBE, serv, &answer);
    382 
     382       
    383383        rc = async_data_write_start(exch, (void *) fs_name,
    384384            str_size(fs_name));
    385 
     385       
    386386        async_wait_for(req, &rc);
    387 
     387       
    388388        if (rc != EOK) {
    389389                vfs_exchange_end(exch);
    390390                return rc;
    391391        }
    392 
     392       
    393393        rc = async_data_read_start(exch, info, sizeof(*info));
    394394        vfs_exchange_end(exch);
    395 
     395       
    396396        return rc;
    397397}
     
    620620{
    621621        errno_t rc, rc1;
    622 
     622       
    623623        if (!mountedfd)
    624624                flags |= VFS_MOUNT_NO_REF;
    625625        if (mp < 0)
    626626                flags |= VFS_MOUNT_CONNECT_ONLY;
    627 
     627       
    628628        ipc_call_t answer;
    629629        async_exch_t *exch = vfs_exchange_begin();
     
    643643        if (mountedfd)
    644644                *mountedfd = (int) IPC_GET_ARG1(answer);
    645 
     645       
    646646        if (rc != EOK)
    647647                return rc;
     
    665665        int null_id = -1;
    666666        char null[LOC_NAME_MAXLEN];
    667 
     667       
    668668        if (str_cmp(fqsn, "") == 0) {
    669669                /*
     
    671671                */
    672672                null_id = loc_null_create();
    673 
     673               
    674674                if (null_id == -1)
    675675                        return ENOMEM;
    676 
     676               
    677677                snprintf(null, LOC_NAME_MAXLEN, "null/%d", null_id);
    678678                fqsn = null;
    679679        }
    680 
     680       
    681681        if (flags & IPC_FLAG_BLOCKING)
    682682                flags = VFS_MOUNT_BLOCKING;
    683683        else
    684684                flags = 0;
    685 
     685       
    686686        service_id_t service_id;
    687687        errno_t res = loc_service_get_id(fqsn, &service_id, flags);
     
    689689                if (null_id != -1)
    690690                        loc_null_destroy(null_id);
    691 
     691               
    692692                return res;
    693693        }
    694 
     694       
    695695        size_t mpa_size;
    696696        char *mpa = vfs_absolutize(mp, &mpa_size);
     
    698698                if (null_id != -1)
    699699                        loc_null_destroy(null_id);
    700 
     700               
    701701                return ENOMEM;
    702702        }
    703 
     703       
    704704        fibril_mutex_lock(&root_mutex);
    705 
     705       
    706706        errno_t rc;
    707 
     707       
    708708        if (str_cmp(mpa, "/") == 0) {
    709709                /* Mounting root. */
    710 
     710               
    711711                if (root_fd >= 0) {
    712712                        fibril_mutex_unlock(&root_mutex);
     
    715715                        return EBUSY;
    716716                }
    717 
     717               
    718718                int root;
    719719                rc = vfs_mount(-1, fs_name, service_id, opts, flags, instance,
     
    728728                        return EINVAL;
    729729                }
    730 
     730               
    731731                int mpfd;
    732732                rc = vfs_walk(root_fd, mpa, WALK_DIRECTORY, &mpfd);
     
    737737                }
    738738        }
    739 
     739       
    740740        fibril_mutex_unlock(&root_mutex);
    741 
     741       
    742742        if ((rc != EOK) && (null_id != -1))
    743743                loc_null_destroy(null_id);
    744 
     744       
    745745        return (errno_t) rc;
    746746}
     
    759759        errno_t rc = async_req_2_0(exch, VFS_IN_OPEN, file, mode);
    760760        vfs_exchange_end(exch);
    761 
     761       
    762762        return rc;
    763763}
     
    788788        errno_t rc = async_req_1_0(exch, VFS_IN_PUT, file);
    789789        vfs_exchange_end(exch);
    790 
     790       
    791791        return rc;
    792792}
     
    845845        uint8_t *bp = (uint8_t *) buf;
    846846        errno_t rc;
    847 
     847       
    848848        do {
    849849                bp += cnt;
     
    852852                rc = vfs_read_short(file, *pos, bp, nbyte - nr, &cnt);
    853853        } while (rc == EOK && cnt > 0 && (nbyte - nr - cnt) > 0);
    854 
     854       
    855855        if (rc != EOK) {
    856856                *nread = nr;
    857857                return rc;
    858858        }
    859 
     859       
    860860        nr += cnt;
    861861        *pos += cnt;
     
    885885        ipc_call_t answer;
    886886        aid_t req;
    887 
     887       
    888888        if (nbyte > DATA_XFER_LIMIT)
    889889                nbyte = DATA_XFER_LIMIT;
    890 
    891         async_exch_t *exch = vfs_exchange_begin();
    892 
     890       
     891        async_exch_t *exch = vfs_exchange_begin();
     892       
    893893        req = async_send_3(exch, VFS_IN_READ, file, LOWER32(pos),
    894894            UPPER32(pos), &answer);
     
    896896
    897897        vfs_exchange_end(exch);
    898 
     898       
    899899        if (rc == EOK)
    900900                async_wait_for(req, &rc);
    901901        else
    902902                async_forget(req);
    903 
     903       
    904904        if (rc != EOK)
    905905                return rc;
    906 
     906       
    907907        *nread = (ssize_t) IPC_GET_ARG1(answer);
    908908        return EOK;
     
    926926        errno_t rc_orig;
    927927        aid_t req;
    928 
     928       
    929929        size_t olda_size;
    930930        char *olda = vfs_absolutize(old, &olda_size);
     
    938938                return ENOMEM;
    939939        }
    940 
     940       
    941941        async_exch_t *exch = vfs_exchange_begin();
    942942        int root = vfs_root();
     
    946946                return ENOENT;
    947947        }
    948 
     948       
    949949        req = async_send_1(exch, VFS_IN_RENAME, root, NULL);
    950950        rc = async_data_write_start(exch, olda, olda_size);
     
    994994            UPPER32(length));
    995995        vfs_exchange_end(exch);
    996 
     996       
    997997        return rc;
    998998}
     
    10561056        errno_t rc;
    10571057        aid_t req;
    1058 
    1059         async_exch_t *exch = vfs_exchange_begin();
    1060 
     1058       
     1059        async_exch_t *exch = vfs_exchange_begin();
     1060       
    10611061        req = async_send_1(exch, VFS_IN_STAT, file, NULL);
    10621062        rc = async_data_read_start(exch, (void *) stat, sizeof(vfs_stat_t));
    10631063        if (rc != EOK) {
    10641064                vfs_exchange_end(exch);
    1065 
     1065               
    10661066                errno_t rc_orig;
    10671067                async_wait_for(req, &rc_orig);
    1068 
     1068               
    10691069                if (rc_orig != EOK)
    10701070                        rc = rc_orig;
    1071 
    1072                 return rc;
    1073         }
    1074 
     1071               
     1072                return rc;
     1073        }
     1074       
    10751075        vfs_exchange_end(exch);
    10761076        async_wait_for(req, &rc);
    1077 
     1077       
    10781078        return rc;
    10791079}
     
    10921092        if (rc != EOK)
    10931093                return rc;
    1094 
     1094       
    10951095        rc = vfs_stat(file, stat);
    10961096
     
    11381138        if (rc != EOK)
    11391139                return rc;
    1140 
     1140       
    11411141        rc = vfs_statfs(file, st);
    11421142
     
    11571157        errno_t rc = async_req_1_0(exch, VFS_IN_SYNC, file);
    11581158        vfs_exchange_end(exch);
    1159 
     1159       
    11601160        return rc;
    11611161}
     
    11781178        errno_t rc;
    11791179        aid_t req;
    1180 
    1181         async_exch_t *exch = vfs_exchange_begin();
    1182 
     1180       
     1181        async_exch_t *exch = vfs_exchange_begin();
     1182       
    11831183        req = async_send_2(exch, VFS_IN_UNLINK, parent, expect, NULL);
    11841184        rc = async_data_write_start(exch, child, str_size(child));
    1185 
    1186         vfs_exchange_end(exch);
    1187 
     1185       
     1186        vfs_exchange_end(exch);
     1187       
    11881188        errno_t rc_orig;
    11891189        async_wait_for(req, &rc_orig);
    1190 
     1190       
    11911191        if (rc_orig != EOK)
    11921192                return (errno_t) rc_orig;
     
    12191219
    12201220        rc = vfs_unlink(parent, child, expect);
    1221 
     1221       
    12221222        free(child);
    12231223        vfs_put(parent);
     
    12521252        if (rc != EOK)
    12531253                return rc;
    1254 
     1254       
    12551255        rc = vfs_unmount(mp);
    12561256        vfs_put(mp);
     
    12701270{
    12711271        async_exch_t *exch = vfs_exchange_begin();
    1272 
     1272       
    12731273        ipc_call_t answer;
    12741274        aid_t req = async_send_2(exch, VFS_IN_WALK, parent, flags, &answer);
    12751275        errno_t rc = async_data_write_start(exch, path, str_size(path));
    12761276        vfs_exchange_end(exch);
    1277 
     1277               
    12781278        errno_t rc_orig;
    12791279        async_wait_for(req, &rc_orig);
     
    12811281        if (rc_orig != EOK)
    12821282                return (errno_t) rc_orig;
    1283 
     1283               
    12841284        if (rc != EOK)
    12851285                return (errno_t) rc;
    1286 
     1286       
    12871287        *handle = (int) IPC_GET_ARG1(answer);
    12881288        return EOK;
     
    13491349        ipc_call_t answer;
    13501350        aid_t req;
    1351 
     1351       
    13521352        if (nbyte > DATA_XFER_LIMIT)
    13531353                nbyte = DATA_XFER_LIMIT;
    1354 
    1355         async_exch_t *exch = vfs_exchange_begin();
    1356 
     1354       
     1355        async_exch_t *exch = vfs_exchange_begin();
     1356       
    13571357        req = async_send_3(exch, VFS_IN_WRITE, file, LOWER32(pos),
    13581358            UPPER32(pos), &answer);
    13591359        rc = async_data_write_start(exch, (void *) buf, nbyte);
    1360 
    1361         vfs_exchange_end(exch);
    1362 
     1360       
     1361        vfs_exchange_end(exch);
     1362       
    13631363        if (rc == EOK)
    13641364                async_wait_for(req, &rc);
     
    13681368        if (rc != EOK)
    13691369                return rc;
    1370 
     1370       
    13711371        *nwritten = (ssize_t) IPC_GET_ARG1(answer);
    13721372        return EOK;
Note: See TracChangeset for help on using the changeset viewer.