Changes between Version 5 and Version 6 of FilesystemAPITutorial


Ignore:
Timestamp:
2017-04-09T08:30:26Z (8 years ago)
Author:
Jakub Jermář
Comment:

Add paragraph on renaming

Legend:

Unmodified
Added
Removed
Modified
  • FilesystemAPITutorial

    v5 v6  
    152152
    153153By passing the third argument to `vfs_unlink()` above, we are making sure that we won't accidentally remove some other link called `hello` created by someone else after the original `hello` had been removed. Note that this argument can be -1 if we don't care.
     154
     155== Renaming a file ==
     156
     157In order to rename a file, one needs to use `vfs_rename_path()`:
     158
     159{{{
     160int rc = vfs_rename_path("/foo/bar", "/foo/bar.txt");
     161if (rc != EOK)
     162        return rc;
     163}}}
     164
     165In this case, this is not a convenience wrapper, but the actual first-class API. The reason there is no `vfs_rename()` that would operate on file handles in a similar way that `vfs_link()` and `vfs_unlink()` do is security considerations. The `VFS` server needs to prevent pathologies such as renaming `/a/b` to `/a/b/c` (creates a loop in the filestem). The `VFS` server detects such attempts lexically so it needs to know full paths in this case.