Lines Matching refs:path

107 	making the access path vnode->mount->covers_vnode->mount->... safe if a
246 static fssh_status_t vnode_path_to_vnode(struct vnode *vnode, char *path,
251 static fssh_status_t fd_and_path_to_vnode(int fd, char *path,
995 /** \brief Gets the directory path and leaf name for a given path.
997 * The supplied \a path is transformed to refer to the directory part of
998 * the entry identified by the original path, and into the buffer \a filename
1000 * Neither the returned path nor the leaf name can be expected to be
1003 * \param path The path to be analyzed. Must be able to store at least one
1012 get_dir_path_and_leaf(char *path, char *filename)
1014 char *p = fssh_strrchr(path, '/');
1017 FUNCTION(("get_dir_path_and_leaf(path = %s)\n", path));
1020 // this path is single segment with no '/' in it
1022 if (fssh_strlcpy(filename, path, FSSH_B_FILE_NAME_LENGTH) >= FSSH_B_FILE_NAME_LENGTH)
1024 fssh_strcpy(path, ".");
1028 // special case: the path ends in '/'
1031 // normal leaf: replace the leaf portion of the path with a '.'
1084 /*! Returns the vnode for the relative path starting at the specified \a vnode.
1085 \a path must not be NULL.
1086 If it returns successfully, \a path contains the name of the last path
1087 component. This function clobbers the buffer pointed to by \a path only
1093 vnode_path_to_vnode(struct vnode *vnode, char *path, bool traverseLeafLink,
1099 FUNCTION(("vnode_path_to_vnode(vnode = %p, path = %s)\n", vnode, path));
1101 if (path == NULL) {
1110 TRACE(("vnode_path_to_vnode: top of loop. p = %p, p = '%s'\n", path, path));
1113 if (path[0] == '\0')
1116 // walk to find the next path component ("path" will point to a single
1117 // path component), and filter out multiple slashes
1118 for (nextPath = path + 1; *nextPath != '\0' && *nextPath != '/'; nextPath++);
1128 // vnode so we pass the '..' path to the underlying filesystem
1129 if (!fssh_strcmp("..", path)
1144 // Tell the filesystem to get the vnode of this path component (if we got the
1147 status = lookup_dir_entry(vnode, path, &nextVnode);
1198 path = buffer;
1199 if (path[0] == '/') {
1203 while (*++path == '/')
1212 status = vnode_path_to_vnode(vnode, path, traverseLeafLink, count + 1,
1227 path = nextPath;
1247 path_to_vnode(char *path, bool traverseLink, struct vnode **_vnode,
1252 FUNCTION(("path_to_vnode(path = \"%s\")\n", path));
1254 if (!path)
1258 if (*path == '/') {
1264 while (*++path == '/')
1281 return vnode_path_to_vnode(start, path, traverseLink, 0, _vnode, _parentID);
1285 /** Returns the vnode in the next to last segment of the path, and returns
1287 * The path buffer must be able to store at least one additional character.
1291 path_to_dir_vnode(char *path, struct vnode **_vnode, char *filename, bool kernel)
1293 fssh_status_t status = get_dir_path_and_leaf(path, filename);
1297 return path_to_vnode(path, true, _vnode, NULL, kernel);
1302 * to by a FD + path pair.
1304 * \a path must be given in either case. \a fd might be omitted, in which
1305 * case \a path is either an absolute path or one relative to the current
1306 * directory. If both a supplied and \a path is relative it is reckoned off
1307 * of the directory referred to by \a fd. If \a path is absolute \a fd is
1314 * \param path The absolute or relative path. Must not be \c NULL. The buffer
1316 * string one character longer than the path it contains.
1327 fd_and_path_to_dir_vnode(int fd, char *path, struct vnode **_vnode,
1330 if (!path)
1333 return path_to_dir_vnode(path, _vnode, filename, kernel);
1335 fssh_status_t status = get_dir_path_and_leaf(path, filename);
1339 return fd_and_path_to_vnode(fd, path, true, _vnode, NULL, kernel);
1419 /** Gets the full path to a given directory vnode.
1427 * Note that the path may not be correct the time this function returns!
1428 * It doesn't use any locking to prevent returning the correct path, as
1429 * paths aren't safe anyway: the path to a file can change at any time.
1431 * It might be a good idea, though, to check if the returned path exists
1448 char *path = pathBuffer.LockBuffer();
1465 path[--insert] = '\0';
1500 // path
1513 // add the name in front of the current path
1521 fssh_memcpy(path + insert, name, length);
1522 path[--insert] = '/';
1525 // the root dir will result in an empty path: fix it
1526 if (path[insert] == '\0')
1527 path[--insert] = '/';
1529 TRACE((" path is: %s\n", path + insert));
1531 // copy the path to the output buffer
1534 fssh_memcpy(buffer, path + insert, length);
1544 /** Checks the length of every path component, and adds a '.'
1545 * if the path ends in a slash.
1546 * The given path buffer must be able to store at least one
1555 // check length of every path component
1573 // complete path if there is a slash at the end
1626 /** Gets the vnode from an FD + path combination. If \a fd is lower than zero,
1627 * only the path will be considered. In this case, the \a path must not be
1629 * If \a fd is a valid file descriptor, \a path may be NULL for directories,
1634 fd_and_path_to_vnode(int fd, char *path, bool traverseLeafLink,
1637 if (fd < 0 && !path)
1640 if (fd < 0 || (path != NULL && path[0] == '/')) {
1641 // no FD or absolute path
1642 return path_to_vnode(path, traverseLeafLink, _vnode, _parentID, kernel);
1645 // FD only, or FD + relative path
1650 if (path != NULL) {
1651 return vnode_path_to_vnode(vnode, path, traverseLeafLink, 0,
1655 // there is no relative path to take into account
2350 vfs_get_vnode_from_path(const char *path, bool kernel, void **_vnode)
2352 TRACE(("vfs_get_vnode_from_path: entry. path = '%s', kernel %d\n", path, kernel));
2359 fssh_strlcpy(buffer, path, pathBuffer.BufferSize());
2450 vfs_get_fs_node_from_path(fssh_fs_volume *volume, const char *path,
2453 TRACE(("vfs_get_fs_node_from_path(volume = %p (%ld), path = \"%s\", "
2454 "kernel %d)\n", volume, volume->id, path, kernel));
2466 fssh_strlcpy(buffer, path, pathBuffer.BufferSize());
2497 /** Finds the full path to the file that contains the module \a moduleName,
2512 char *path;
2521 // the path buffer had been clobbered by the above call
2526 path = pathBuffer + length;
2543 fssh_memcpy(path, moduleName, length);
2544 path[length] = '\0';
2547 status = vnode_path_to_vnode(dir, path, true, 0, &file, NULL);
2555 path[length] = '/';
2556 path[length + 1] = '\0';
2557 path += length + 1;
2584 /** \brief Normalizes a given path.
2586 * The path must refer to an existing or non-existing entry in an existing
2587 * directory, that is chopping off the leaf component the remaining path must
2595 * normalized path (well, that is pretty much the definition of `normalized',
2598 * \param path The path to be normalized.
2599 * \param buffer The buffer into which the normalized path will be written.
2603 * if the path is relative (to get the CWD).
2608 vfs_normalize_path(const char *path, char *buffer, fssh_size_t bufferSize,
2611 if (!path || !buffer || bufferSize < 1)
2614 TRACE(("vfs_normalize_path(`%s')\n", path));
2616 // copy the supplied path to the stack, so it can be modified
2622 if (fssh_strlcpy(mutablePath, path, FSSH_B_PATH_NAME_LENGTH) >= FSSH_B_PATH_NAME_LENGTH)
2645 // get the directory path
2649 TRACE(("vfs_normalize_path(): failed to get dir path: %s\n", strerror(error)));
2733 bool kernel, char *path, fssh_size_t pathLength)
2753 // get the directory path
2754 status = dir_vnode_to_path(vnode, path, pathLength);
2763 if ((fssh_strcmp(path, "/") && fssh_strlcat(path, "/", pathLength)
2765 || fssh_strlcat(path, leaf, pathLength) >= pathLength) {
3097 file_create(int fd, char *path, int openMode, int perms, bool kernel)
3103 FUNCTION(("file_create: path '%s', omode %x, perms %d, kernel %d\n", path, openMode, perms, kernel));
3106 status = fd_and_path_to_dir_vnode(fd, path, &directory, name, kernel);
3143 file_open(int fd, char *path, int openMode, bool kernel)
3148 FUNCTION(("file_open: fd: %d, entry path = '%s', omode %d, kernel %d\n",
3149 fd, path, openMode, kernel));
3151 // get the vnode matching the vnode + path combination
3154 status = fd_and_path_to_vnode(fd, path, traverse, &vnode, &parentID, kernel);
3288 dir_create(int fd, char *path, int perms, bool kernel)
3294 FUNCTION(("dir_create: path '%s', perms %d, kernel %d\n", path, perms, kernel));
3296 status = fd_and_path_to_dir_vnode(fd, path, &vnode, filename, kernel);
3338 dir_open(int fd, char *path, bool kernel)
3342 FUNCTION(("dir_open: fd: %d, entry path = '%s', kernel %d\n", fd, path, kernel));
3344 // get the vnode matching the vnode + path combination
3347 status = fd_and_path_to_vnode(fd, path, true, &vnode, &parentID, kernel);
3471 dir_remove(int fd, char *path, bool kernel)
3477 if (path != NULL) {
3478 // we need to make sure our path name doesn't stop with "/", ".", or ".."
3479 char *lastSlash = fssh_strrchr(path, '/');
3486 while (lastSlash > path && lastSlash[-1] == '/') {
3495 } else if (!fssh_strcmp(path, ".."))
3499 status = fd_and_path_to_dir_vnode(fd, path, &directory, name, kernel);
3701 common_read_link(int fd, char *path, char *buffer, fssh_size_t *_bufferSize,
3707 status = fd_and_path_to_vnode(fd, path, false, &vnode, NULL, kernel);
3722 common_create_symlink(int fd, char *path, const char *toPath, int mode,
3725 // path validity checks have to be in the calling function!
3730 FUNCTION(("common_create_symlink(fd = %d, path = %s, toPath = %s, mode = %d, kernel = %d)\n", fd, path, toPath, mode, kernel));
3732 status = fd_and_path_to_dir_vnode(fd, path, &vnode, name, kernel);
3748 common_create_link(char *path, char *toPath, bool kernel)
3750 // path validity checks have to be in the calling function!
3755 FUNCTION(("common_create_link(path = %s, toPath = %s, kernel = %d)\n", path, toPath, kernel));
3757 status = path_to_dir_vnode(path, &directory, name, kernel);
3785 common_unlink(int fd, char *path, bool kernel)
3791 FUNCTION(("common_unlink: fd: %d, path '%s', kernel %d\n", fd, path, kernel));
3793 status = fd_and_path_to_dir_vnode(fd, path, &vnode, filename, kernel);
3809 common_access(char *path, int mode, bool kernel)
3814 status = path_to_vnode(path, true, &vnode, NULL, kernel);
3830 common_rename(int fd, char *path, int newFD, char *newPath, bool kernel)
3837 FUNCTION(("common_rename(fd = %d, path = %s, newFD = %d, newPath = %s, kernel = %d)\n", fd, path, newFD, newPath, kernel));
3839 status = fd_and_path_to_dir_vnode(fd, path, &fromVnode, fromName, kernel);
3905 common_path_read_stat(int fd, char *path, bool traverseLeafLink,
3911 FUNCTION(("common_path_read_stat: fd: %d, path '%s', stat %p,\n", fd, path, stat));
3913 status = fd_and_path_to_vnode(fd, path, traverseLeafLink, &vnode, NULL, kernel);
3931 common_path_write_stat(int fd, char *path, bool traverseLeafLink,
3937 FUNCTION(("common_write_stat: fd: %d, path '%s', stat %p, stat_mask %d, kernel %d\n", fd, path, stat, statMask, kernel));
3939 status = fd_and_path_to_vnode(fd, path, traverseLeafLink, &vnode, NULL, kernel);
3955 attr_dir_open(int fd, char *path, bool kernel)
3960 FUNCTION(("attr_dir_open(fd = %d, path = '%s', kernel = %d)\n", fd, path, kernel));
3962 status = fd_and_path_to_vnode(fd, path, true, &vnode, NULL, kernel);
4555 fs_mount(char *path, const char *device, const char *fsName, uint32_t flags,
4561 FUNCTION(("fs_mount: entry. path = '%s', fs_name = '%s'\n", path, fsName));
4563 // The path is always safe, we just have to make sure that fsName is
4581 // normalize the device path
4589 // correct path to file device
4645 if (fssh_strcmp(path, "/") != 0) {
4658 status = path_to_vnode(path, true, &coveredVnode, NULL, kernel);
4734 fs_unmount(char *path, uint32_t flags, bool kernel)
4740 FUNCTION(("vfs_unmount: entry. path = '%s', kernel %d\n", path, kernel));
4742 err = path_to_vnode(path, true, &vnode, NULL, kernel);
5031 set_cwd(int fd, char *path, bool kernel)
5039 FUNCTION(("set_cwd: path = \'%s\'\n", path));
5041 // Get vnode for passed path, and bail if it failed
5042 status = fd_and_path_to_vnode(fd, path, true, &vnode, NULL, kernel);
5082 _kern_mount(const char *path, const char *device, const char *fsName,
5085 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5094 _kern_unmount(const char *path, uint32_t flags)
5096 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5157 /** \brief Opens a node specified by a FD + path pair.
5159 * At least one of \a fd and \a path must be specified.
5161 * FD. If only a path is given, this path is opened. If both are given and
5162 * the path is absolute, \a fd is ignored; a relative path is reckoned off
5166 * \param path The absolute or relative path. May be \c NULL.
5173 _kern_open(int fd, const char *path, int openMode, int perms)
5176 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5213 /** \brief Opens a directory specified by a FD + path pair.
5215 * At least one of \a fd and \a path must be specified.
5217 * FD. If only a path is given, this path is opened. If both are given and
5218 * the path is absolute, \a fd is ignored; a relative path is reckoned off
5222 * \param path The absolute or relative path. May be \c NULL.
5228 _kern_open_dir(int fd, const char *path)
5230 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5273 /** \brief Creates a directory specified by a FD + path pair.
5275 * \a path must always be specified (it contains the name of the new directory
5276 * at least). If only a path is given, this path identifies the location at
5277 * which the directory shall be created. If both \a fd and \a path are given and
5278 * the path is absolute, \a fd is ignored; a relative path is reckoned off
5282 * \param path The absolute or relative path. Must not be \c NULL.
5289 _kern_create_dir(int fd, const char *path, int perms)
5291 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5300 _kern_remove_dir(int fd, const char *path)
5302 if (path) {
5303 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5314 /** \brief Reads the contents of a symlink referred to by a FD + path pair.
5316 * At least one of \a fd and \a path must be specified.
5318 * identified by this FD. If only a path is given, this path identifies the
5319 * symlink to be read. If both are given and the path is absolute, \a fd is
5320 * ignored; a relative path is reckoned off of the directory (!) identified
5326 * \param path The absolute or relative path. May be \c NULL.
5334 _kern_read_link(int fd, const char *path, char *buffer, fssh_size_t *_bufferSize)
5336 if (path) {
5337 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5349 /** \brief Creates a symlink specified by a FD + path pair.
5351 * \a path must always be specified (it contains the name of the new symlink
5352 * at least). If only a path is given, this path identifies the location at
5353 * which the symlink shall be created. If both \a fd and \a path are given and
5354 * the path is absolute, \a fd is ignored; a relative path is reckoned off
5358 * \param toPath The absolute or relative path. Must not be \c NULL.
5365 _kern_create_symlink(int fd, const char *path, const char *toPath, int mode)
5367 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5384 _kern_create_link(const char *path, const char *toPath)
5386 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5396 /** \brief Removes an entry specified by a FD + path pair from its directory.
5398 * \a path must always be specified (it contains at least the name of the entry
5399 * to be deleted). If only a path is given, this path identifies the entry
5400 * directly. If both \a fd and \a path are given and the path is absolute,
5401 * \a fd is ignored; a relative path is reckoned off of the directory (!)
5405 * \param path The absolute or relative path. Must not be \c NULL.
5411 _kern_unlink(int fd, const char *path)
5413 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5421 /** \brief Moves an entry specified by a FD + path pair to a an entry specified
5422 * by another FD + path pair.
5425 * the name of the entry). If only a path is given, this path identifies the
5426 * entry directly. If both a FD and a path are given and the path is absolute,
5427 * the FD is ignored; a relative path is reckoned off of the directory (!)
5431 * \param oldPath The absolute or relative path of the old location. Must not
5434 * \param newPath The absolute or relative path of the new location. Must not
5454 _kern_access(const char *path, int mode)
5456 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5464 /** \brief Reads stat data of an entity specified by a FD + path pair.
5467 * of the FD (node, attr, attr dir etc.) is performed. If only \a path is
5468 * given, this path identifies the entry for whose node to retrieve the
5469 * stat data. If both \a fd and \a path are given and the path is absolute,
5470 * \a fd is ignored; a relative path is reckoned off of the directory (!)
5475 * \param path The absolute or relative path. Must not be \c NULL.
5476 * \param traverseLeafLink If \a path is given, \c true specifies that the
5485 _kern_read_stat(int fd, const char *path, bool traverseLeafLink,
5501 if (path) {
5502 // path given: get the stat of the node referred to by (fd, path)
5503 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5510 // no path given: get the FD and use the FD operation
5531 /** \brief Writes stat data of an entity specified by a FD + path pair.
5534 * of the FD (node, attr, attr dir etc.) is performed. If only \a path is
5535 * given, this path identifies the entry for whose node to write the
5536 * stat data. If both \a fd and \a path are given and the path is absolute,
5537 * \a fd is ignored; a relative path is reckoned off of the directory (!)
5542 * \param path The absolute or relative path. Must not be \c NULL.
5543 * \param traverseLeafLink If \a path is given, \c true specifies that the
5554 _kern_write_stat(int fd, const char *path, bool traverseLeafLink,
5571 if (path) {
5572 // path given: write the stat of the node referred to by (fd, path)
5573 KPath pathBuffer(path, false, FSSH_B_PATH_NAME_LENGTH + 1);
5580 // no path given: get the FD and use the FD operation
5599 _kern_open_attr_dir(int fd, const char *path)
5605 if (path != NULL)
5606 pathBuffer.SetTo(path);
5608 return attr_dir_open(fd, path ? pathBuffer.LockBuffer() : NULL, true);
5679 _kern_setcwd(int fd, const char *path)
5685 if (path != NULL)
5686 pathBuffer.SetTo(path);
5688 return set_cwd(fd, path != NULL ? pathBuffer.LockBuffer() : NULL, true);
5733 char* path, fssh_size_t pathLength)
5735 return vfs_entry_ref_to_path(device, inode, leaf, true, path, pathLength);