Changeset a6fc88a in mainline for uspace/lib/c/generic/vfs/vfs.c


Ignore:
Timestamp:
2017-04-03T21:15:17Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
Children:
8fe46a0
Parents:
ea4a3f0
Message:

Let vfs_link() and vfs_link_path() return the linked file handle

Add an output argument to both vfs_link() and vfs_link_path() so that the
client may receive the file handle of the linked file or directory. This
makes it easy to work with the new file or directory as it is ready to be
opened or in case of a directory to use it as a parent for further
operations without the need for additional vfs_lookup().

File:
1 edited

Legend:

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

    rea4a3f0 ra6fc88a  
    359359 * @param kind          Kind of the object to be created: KIND_FILE or
    360360 *                      KIND_DIRECTORY
     361 * @param[out] linkedfd If not NULL, will receive a file handle to the linked
     362 *                      child
    361363 * @return              EOK on success or a negative error code
    362364 */
    363 int vfs_link(int parent, const char *child, vfs_file_kind_t kind)
     365int vfs_link(int parent, const char *child, vfs_file_kind_t kind, int *linkedfd)
    364366{
    365367        int flags = (kind == KIND_DIRECTORY) ? WALK_DIRECTORY : WALK_REGULAR;
     
    369371                return file;
    370372
    371         vfs_put(file);
     373        if (linkedfd)
     374                *linkedfd = file;
     375        else
     376                vfs_put(file);
    372377
    373378        return EOK;
     
    384389 * @param kind          Kind of the object to be created: KIND_FILE or
    385390 *                      KIND_DIRECTORY
     391 * @param[out] linkedfd If not NULL, will receive a file handle to the linked
     392 *                      child
    386393 * @return              EOK on success or a negative error code
    387394 */
    388 int vfs_link_path(const char *path, vfs_file_kind_t kind)
     395int vfs_link_path(const char *path, vfs_file_kind_t kind, int *linkedfd)
    389396{
    390397        char *child;
     
    393400                return parent;
    394401
    395         int rc = vfs_link(parent, child, kind);
     402        int rc = vfs_link(parent, child, kind, linkedfd);
    396403
    397404        free(child);
Note: See TracChangeset for help on using the changeset viewer.