Changeset 64ffd83 in mainline for uspace/lib/c


Ignore:
Timestamp:
2018-07-24T09:43:38Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bec18a9
Parents:
05208d9
git-author:
Jiri Svoboda <jiri@…> (2018-07-23 18:41:45)
git-committer:
Jiri Svoboda <jiri@…> (2018-07-24 09:43:38)
Message:

Configuring mount point for (newly created) paritions.

Location:
uspace/lib/c
Files:
3 edited

Legend:

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

    r05208d9 r64ffd83  
    4040#include <stdlib.h>
    4141#include <str.h>
     42#include <vfs/vfs.h>
    4243#include <vol.h>
    4344
     
    220221        exch = async_exchange_begin(vol->sess);
    221222        aid_t req = async_send_1(exch, VOL_PART_INFO, sid, &answer);
     223
    222224        errno_t rc = async_data_read_start(exch, vinfo, sizeof(vol_part_info_t));
    223225        async_exchange_end(exch);
    224 
    225226        if (rc != EOK) {
    226227                async_forget(req);
     
    294295}
    295296
    296 /** Create file system. */
     297/** Create file system.
     298 *
     299 * @param vol Volume service
     300 * @param sid Partition service ID
     301 * @param fstype File system type
     302 * @param label Volume label
     303 * @param mountp Mount point
     304 *
     305 * @return EOK on success or an error code
     306 */
    297307errno_t vol_part_mkfs(vol_t *vol, service_id_t sid, vol_fstype_t fstype,
    298     const char *label)
     308    const char *label, const char *mountp)
    299309{
    300310        async_exch_t *exch;
     
    304314        exch = async_exchange_begin(vol->sess);
    305315        aid_t req = async_send_2(exch, VOL_PART_MKFS, sid, fstype, &answer);
     316
    306317        retval = async_data_write_start(exch, label, str_size(label));
    307         async_exchange_end(exch);
    308 
    309318        if (retval != EOK) {
     319                async_exchange_end(exch);
    310320                async_forget(req);
    311321                return retval;
    312322        }
    313323
     324        retval = async_data_write_start(exch, mountp, str_size(mountp));
     325        if (retval != EOK) {
     326                async_exchange_end(exch);
     327                async_forget(req);
     328                return retval;
     329        }
     330
     331        async_exchange_end(exch);
    314332        async_wait_for(req, &retval);
    315333
     
    394412}
    395413
     414/** Validate mount point.
     415 *
     416 * Verify that mount point is valid. A valid mount point is
     417 * one of:
     418 *  - 'Auto'
     419 *  - 'None'
     420 *  - /path (string beginning with '/') to an existing directory
     421 *
     422 * @return EOK if mount point is in valid, EINVAL if the format is invalid,
     423 *         ENOENT if the directory does not exist
     424 */
     425errno_t vol_mountp_validate(const char *mountp)
     426{
     427        errno_t rc;
     428        vfs_stat_t stat;
     429
     430        if (str_cmp(mountp, "Auto") == 0 || str_cmp(mountp, "auto") == 0)
     431                return EOK;
     432
     433        if (str_casecmp(mountp, "None") == 0 || str_cmp(mountp, "none") == 0)
     434                return EOK;
     435
     436        if (mountp[0] == '/') {
     437                rc = vfs_stat_path(mountp, &stat);
     438                if (rc != EOK || !stat.is_directory)
     439                        return ENOENT;
     440
     441                return EOK;
     442        }
     443
     444        return EINVAL;
     445}
     446
    396447/** @}
    397448 */
  • uspace/lib/c/include/ipc/vol.h

    r05208d9 r64ffd83  
    3737
    3838#define VOL_LABEL_MAXLEN 63
     39#define VOL_MOUNTP_MAXLEN 4096
    3940
    4041typedef enum {
  • uspace/lib/c/include/vol.h

    r05208d9 r64ffd83  
    5151extern errno_t vol_part_empty(vol_t *, service_id_t);
    5252extern errno_t vol_part_get_lsupp(vol_t *, vol_fstype_t, vol_label_supp_t *);
    53 extern errno_t vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *);
     53extern errno_t vol_part_mkfs(vol_t *, service_id_t, vol_fstype_t, const char *,
     54    const char *);
    5455
    5556extern errno_t vol_fstype_format(vol_fstype_t, char **);
    5657extern errno_t vol_pcnt_fs_format(vol_part_cnt_t, vol_fstype_t, char **);
     58extern errno_t vol_mountp_validate(const char *);
    5759
    5860#endif
Note: See TracChangeset for help on using the changeset viewer.