Lines Matching refs:fd

43 #include <fd.h>
414 static status_t common_path_read_stat(int fd, char* path, bool traverseLeafLink,
422 static status_t fd_and_path_to_vnode(int fd, char* path, bool traverseLeafLink,
554 FDCloser(int fd, bool kernel) : fFD(fd), fKernel(kernel) {}
561 void SetTo(int fd, bool kernel)
564 fFD = fd;
581 int fd = fFD;
583 return fd;
2379 \a path must be given in either case. \a fd might be omitted, in which
2382 of the directory referred to by \a fd. If \a path is absolute \a fd is
2388 \param fd The FD. May be < 0.
2401 fd_and_path_to_dir_vnode(int fd, char* path, VnodePutter& _vnode,
2408 if (fd < 0)
2415 return fd_and_path_to_vnode(fd, path, true, _vnode, NULL, kernel);
2707 get_fd_and_vnode(int fd, struct vnode** _vnode, bool kernel)
2710 = get_fd(get_current_io_context(kernel), fd);
2729 get_vnode_from_fd(int fd, bool kernel)
2734 descriptor = get_fd(get_current_io_context(kernel), fd);
2747 /*! Gets the vnode from an FD + path combination. If \a fd is lower than zero,
2750 If \a fd is a valid file descriptor, \a path may be NULL for directories,
2754 fd_and_path_to_vnode(int fd, char* path, bool traverseLeafLink,
2757 if (fd < 0 && !path)
2763 if (fd < 0 || (path != NULL && path[0] == '/')) {
2769 struct vnode* vnode = get_vnode_from_fd(fd, kernel);
2793 int fd;
2861 fd = new_fd(context, descriptor);
2862 if (fd < 0) {
2869 fd_set_close_on_exec(context, fd, (openMode & O_CLOEXEC) != 0);
2872 return fd;
3384 struct file_descriptor* fd = context->fds[i];
3385 if (fd == NULL)
3390 fd->type, fd->ops, fd->ref_count, fd->open_count, fd->open_mode,
3391 fd->pos, fd->cookie,
3392 fd->type >= FDTYPE_INDEX && fd->type <= FDTYPE_QUERY
3394 fd->u.vnode);
4012 read_pages(int fd, off_t pos, const iovec* vecs, size_t count,
4018 descriptor = get_fd_and_vnode(fd, &vnode, true);
4031 write_pages(int fd, off_t pos, const iovec* vecs, size_t count,
4037 descriptor = get_fd_and_vnode(fd, &vnode, true);
4051 read_file_io_vec_pages(int fd, const file_io_vec* fileVecs, size_t fileVecCount,
4056 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, true));
4069 write_file_io_vec_pages(int fd, const file_io_vec* fileVecs, size_t fileVecCount,
4074 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, true));
4153 vfs_get_cookie_from_fd(int fd, void** _cookie)
4157 descriptor = get_fd(get_current_io_context(true), fd);
4167 vfs_get_vnode_from_fd(int fd, bool kernel, struct vnode** vnode)
4169 *vnode = get_vnode_from_fd(fd, kernel);
4325 vfs_read_stat(int fd, const char* path, bool traverseLeafLink,
4331 // path given: get the stat of the node referred to by (fd, path)
4336 status = common_path_read_stat(fd, pathBuffer.LockBuffer(),
4341 (get_fd(get_current_io_context(kernel), fd));
5364 int fd = get_new_fd(FDTYPE_FILE, NULL, vnode, cookie, openMode, kernel);
5365 if (fd < 0) {
5369 return fd;
5442 int fd = open_vnode(vnode.Get(), openMode & ~O_CREAT, kernel);
5444 if (fd >= 0)
5447 return fd;
5479 int fd = get_new_fd(FDTYPE_FILE, NULL, vnode.Get(), cookie, openMode, kernel);
5480 if (fd >= 0) {
5482 return fd;
5485 status = fd;
5512 // directory is opened, create a fd
5539 // directory is opened, create a fd
5573 file_create(int fd, char* path, int openMode, int perms, bool kernel)
5581 status_t status = fd_and_path_to_dir_vnode(fd, path, directory, name,
5626 file_open(int fd, char* path, int openMode, bool kernel)
5630 FUNCTION(("file_open: fd: %d, entry path = '%s', omode %d, kernel %d\n",
5631 fd, path, openMode, kernel));
5636 status_t status = fd_and_path_to_vnode(fd, path, traverse, vnode,
5900 dir_create(int fd, char* path, int perms, bool kernel)
5909 status = fd_and_path_to_dir_vnode(fd, path, vnode, filename, kernel);
5958 dir_open(int fd, char* path, bool kernel)
5960 FUNCTION(("dir_open: fd: %d, entry path = '%s', kernel %d\n", fd, path,
5966 status_t status = fd_and_path_to_vnode(fd, path, true, vnode, &parentID,
6094 dir_remove(int fd, char* path, bool kernel)
6125 status = fd_and_path_to_dir_vnode(fd, path, directory, name, kernel);
6152 common_fcntl(int fd, int op, size_t argument, bool kernel)
6156 FUNCTION(("common_fcntl(fd = %d, op = %d, argument = %lx, %s)\n",
6157 fd, op, argument, kernel ? "kernel" : "user"));
6161 FileDescriptorPutter descriptor(get_fd(context, fd));
6188 fd_set_close_on_exec(context, fd, (argument & FD_CLOEXEC) != 0);
6199 status = fd_close_on_exec(context, fd) ? FD_CLOEXEC : 0;
6335 common_sync(int fd, bool kernel)
6337 FUNCTION(("common_fsync: entry. fd %d kernel %d\n", fd, kernel));
6340 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, kernel));
6355 common_lock_node(int fd, bool kernel)
6358 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, kernel));
6375 common_unlock_node(int fd, bool kernel)
6378 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, kernel));
6395 common_preallocate(int fd, off_t offset, off_t length, bool kernel)
6403 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, kernel));
6435 common_read_link(int fd, char* path, char* buffer, size_t* _bufferSize,
6441 status = fd_and_path_to_vnode(fd, path, false, vnode, NULL, kernel);
6455 common_create_symlink(int fd, char* path, const char* toPath, int mode,
6462 FUNCTION(("common_create_symlink(fd = %d, path = %s, toPath = %s, "
6463 "mode = %d, kernel = %d)\n", fd, path, toPath, mode, kernel));
6466 status = fd_and_path_to_dir_vnode(fd, path, vnode, name, kernel);
6516 common_unlink(int fd, char* path, bool kernel)
6521 FUNCTION(("common_unlink: fd: %d, path '%s', kernel %d\n", fd, path,
6525 status = fd_and_path_to_dir_vnode(fd, path, vnode, filename, kernel);
6539 common_access(int fd, char* path, int mode, bool effectiveUserGroup, bool kernel)
6546 status = fd_and_path_to_vnode(fd, path, true, vnode, NULL, kernel);
6560 common_rename(int fd, char* path, int newFD, char* newPath, bool kernel)
6564 FUNCTION(("common_rename(fd = %d, path = %s, newFD = %d, newPath = %s, "
6565 "kernel = %d)\n", fd, path, newFD, newPath, kernel));
6569 status = fd_and_path_to_dir_vnode(fd, path, fromVnode, fromName, kernel);
6639 common_path_read_stat(int fd, char* path, bool traverseLeafLink,
6642 FUNCTION(("common_path_read_stat: fd: %d, path '%s', stat %p,\n", fd, path,
6646 status_t status = fd_and_path_to_vnode(fd, path, traverseLeafLink, vnode,
6658 common_path_write_stat(int fd, char* path, bool traverseLeafLink,
6661 FUNCTION(("common_write_stat: fd: %d, path '%s', stat %p, stat_mask %d, "
6662 "kernel %d\n", fd, path, stat, statMask, kernel));
6665 status_t status = fd_and_path_to_vnode(fd, path, traverseLeafLink, vnode,
6680 attr_dir_open(int fd, char* path, bool traverseLeafLink, bool kernel)
6682 FUNCTION(("attr_dir_open(fd = %d, path = '%s', kernel = %d)\n", fd, path,
6686 status_t status = fd_and_path_to_vnode(fd, path, traverseLeafLink, vnode,
6756 attr_create(int fd, char* path, const char* name, uint32 type,
6764 status_t status = fd_and_path_to_vnode(fd, path, traverse, vnode, NULL,
6780 fd = get_new_fd(FDTYPE_ATTR, NULL, vnode.Get(), cookie, openMode, kernel);
6781 if (fd >= 0) {
6783 return fd;
6786 status = fd;
6798 attr_open(int fd, char* path, const char* name, int openMode, bool kernel)
6805 status_t status = fd_and_path_to_vnode(fd, path, traverse, vnode, NULL,
6822 fd = get_new_fd(FDTYPE_ATTR, NULL, vnode.Get(), cookie, openMode, kernel);
6823 if (fd >= 0) {
6825 return fd;
6828 status = fd;
6968 attr_remove(int fd, const char* name, bool kernel)
6973 FUNCTION(("attr_remove: fd = %d, name = \"%s\", kernel %d\n", fd, name,
6977 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, kernel));
6999 FUNCTION(("attr_rename: from fd = %d, from name = \"%s\", to fd = %d, to "
7048 // get fd for the index directory
7049 int fd;
7050 fd = get_new_fd(FDTYPE_INDEX_DIR, mount, NULL, cookie, O_CLOEXEC, kernel);
7051 if (fd >= 0)
7052 return fd;
7058 status = fd;
7251 // get fd for the index directory
7252 int fd;
7253 fd = get_new_fd(FDTYPE_QUERY, mount, NULL, cookie, O_CLOEXEC, kernel);
7254 if (fd >= 0)
7255 return fd;
7257 status = fd;
8052 fs_read_attr(int fd, const char *attribute, uint32 type, off_t pos,
8055 int attrFD = attr_open(fd, NULL, attribute, O_RDONLY, true);
8095 set_cwd(int fd, char* path, bool kernel)
8104 status_t status = fd_and_path_to_vnode(fd, path, true, vnode, NULL, kernel);
8280 At least one of \a fd and \a path must be specified.
8281 If only \a fd is given, the function opens the node identified by this
8283 the path is absolute, \a fd is ignored; a relative path is reckoned off
8284 of the directory (!) identified by \a fd.
8286 \param fd The FD. May be < 0.
8293 _kern_open(int fd, const char* path, int openMode, int perms)
8300 return file_create(fd, pathBuffer.LockBuffer(), openMode, perms, true);
8302 return file_open(fd, pathBuffer.LockBuffer(), openMode, true);
8333 At least one of \a fd and \a path must be specified.
8334 If only \a fd is given, the function opens the directory identified by this
8336 the path is absolute, \a fd is ignored; a relative path is reckoned off
8337 of the directory (!) identified by \a fd.
8339 \param fd The FD. May be < 0.
8345 _kern_open_dir(int fd, const char* path)
8351 return dir_open(fd, pathBuffer.LockBuffer(), true);
8356 _kern_fcntl(int fd, int op, size_t argument)
8358 return common_fcntl(fd, op, argument, true);
8363 _kern_fsync(int fd)
8365 return common_sync(fd, true);
8370 _kern_lock_node(int fd)
8372 return common_lock_node(fd, true);
8377 _kern_unlock_node(int fd)
8379 return common_unlock_node(fd, true);
8384 _kern_preallocate(int fd, off_t offset, off_t length)
8386 return common_preallocate(fd, offset, length, true);
8402 which the directory shall be created. If both \a fd and \a path are given
8403 and the path is absolute, \a fd is ignored; a relative path is reckoned off
8404 of the directory (!) identified by \a fd.
8406 \param fd The FD. May be < 0.
8413 _kern_create_dir(int fd, const char* path, int perms)
8419 return dir_create(fd, pathBuffer.LockBuffer(), perms, true);
8424 _kern_remove_dir(int fd, const char* path)
8430 return dir_remove(fd, pathBuffer.LockBuffer(), true);
8436 At least one of \a fd and \a path must be specified.
8437 If only \a fd is given, the function the symlink to be read is the node
8439 symlink to be read. If both are given and the path is absolute, \a fd is
8441 by \a fd.
8445 \param fd The FD. May be < 0.
8453 _kern_read_link(int fd, const char* path, char* buffer, size_t* _bufferSize)
8459 return common_read_link(fd, pathBuffer.LockBuffer(),
8468 which the symlink shall be created. If both \a fd and \a path are given and
8469 the path is absolute, \a fd is ignored; a relative path is reckoned off
8470 of the directory (!) identified by \a fd.
8472 \param fd The FD. May be < 0.
8479 _kern_create_symlink(int fd, const char* path, const char* toPath, int mode)
8485 return common_create_symlink(fd, pathBuffer.LockBuffer(),
8508 directly. If both \a fd and \a path are given and the path is absolute,
8509 \a fd is ignored; a relative path is reckoned off of the directory (!)
8510 identified by \a fd.
8512 \param fd The FD. May be < 0.
8518 _kern_unlink(int fd, const char* path)
8524 return common_unlink(fd, pathBuffer.LockBuffer(), true);
8560 _kern_access(int fd, const char* path, int mode, bool effectiveUserGroup)
8566 return common_access(fd, pathBuffer.LockBuffer(), mode, effectiveUserGroup,
8573 If only \a fd is given, the stat operation associated with the type
8576 stat data. If both \a fd and \a path are given and the path is absolute,
8577 \a fd is ignored; a relative path is reckoned off of the directory (!)
8578 identified by \a fd and specifies the entry whose stat data shall be
8581 \param fd The FD. May be < 0.
8591 _kern_read_stat(int fd, const char* path, bool traverseLeafLink,
8607 status = vfs_read_stat(fd, path, traverseLeafLink, stat, true);
8618 If only \a fd is given, the stat operation associated with the type
8621 stat data. If both \a fd and \a path are given and the path is absolute,
8622 \a fd is ignored; a relative path is reckoned off of the directory (!)
8623 identified by \a fd and specifies the entry whose stat data shall be
8626 \param fd The FD. May be < 0.
8638 _kern_write_stat(int fd, const char* path, bool traverseLeafLink,
8657 // path given: write the stat of the node referred to by (fd, path)
8662 status = common_path_write_stat(fd, pathBuffer.LockBuffer(),
8667 (get_fd(get_current_io_context(true), fd));
8682 _kern_open_attr_dir(int fd, const char* path, bool traverseLeafLink)
8688 return attr_dir_open(fd, pathBuffer.LockBuffer(), traverseLeafLink, true);
8693 _kern_open_attr(int fd, const char* path, const char* name, uint32 type,
8701 return attr_create(fd, pathBuffer.LockBuffer(), name, type, openMode,
8705 return attr_open(fd, pathBuffer.LockBuffer(), name, openMode, true);
8710 _kern_remove_attr(int fd, const char* name)
8712 return attr_remove(fd, name, true);
8763 _kern_setcwd(int fd, const char* path)
8769 return set_cwd(fd, pathBuffer.LockBuffer(), true);
9063 _user_open(int fd, const char* userPath, int openMode, int perms)
9078 return file_create(fd, buffer, openMode, perms, false);
9080 return file_open(fd, buffer, openMode, false);
9103 _user_open_dir(int fd, const char* userPath)
9106 return dir_open(fd, NULL, false);
9120 return dir_open(fd, buffer, false);
9128 equivalent to \code _user_open_dir(fd, "..") \endcode. It really is
9134 \param fd A FD referring to a directory.
9142 _user_open_parent_dir(int fd, char* userName, size_t nameLength)
9150 int parentFD = dir_open(fd, (char*)"..", kernel);
9158 struct vnode* dirVNode = get_vnode_from_fd(fd, kernel);
9185 _user_fcntl(int fd, int op, size_t argument)
9187 status_t status = common_fcntl(fd, op, argument, false);
9196 _user_fsync(int fd)
9198 return common_sync(fd, false);
9203 _user_flock(int fd, int operation)
9205 FUNCTION(("_user_fcntl(fd = %d, op = %d)\n", fd, operation));
9219 FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, false));
9255 _user_lock_node(int fd)
9257 return common_lock_node(fd, false);
9262 _user_unlock_node(int fd)
9264 return common_unlock_node(fd, false);
9269 _user_preallocate(int fd, off_t offset, off_t length)
9271 return common_preallocate(fd, offset, length, false);
9294 _user_create_dir(int fd, const char* userPath, int perms)
9308 return dir_create(fd, path, perms, false);
9313 _user_remove_dir(int fd, const char* userPath)
9329 return dir_remove(fd, userPath ? path : NULL, false);
9334 _user_read_link(int fd, const char* userPath, char* userBuffer,
9362 status_t status = common_read_link(fd, userPath ? path : NULL, buffer,
9382 _user_create_symlink(int fd, const char* userPath, const char* userToPath,
9402 return common_create_symlink(fd, path, toPath, mode, false);
9437 _user_unlink(int fd, const char* userPath)
9451 return common_unlink(fd, path, false);
9481 _user_create_fifo(int fd, const char* userPath, mode_t perms)
9498 status = fd_and_path_to_dir_vnode(fd, path, dir, filename, false);
9575 _user_access(int fd, const char* userPath, int mode, bool effectiveUserGroup)
9589 return common_access(fd, path, mode, effectiveUserGroup, false);
9594 _user_read_stat(int fd, const char* userPath, bool traverseLink,
9607 // path given: get the stat of the node referred to by (fd, path)
9621 status = common_path_read_stat(fd, path, traverseLink, &stat, false);
9625 (get_fd(get_current_io_context(false), fd));
9643 _user_write_stat(int fd, const char* userPath, bool traverseLeafLink,
9662 // path given: write the stat of the node referred to by (fd, path)
9676 status = common_path_write_stat(fd, path, traverseLeafLink, &stat,
9681 (get_fd(get_current_io_context(false), fd));
9697 _user_open_attr_dir(int fd, const char* userPath, bool traverseLeafLink)
9713 return attr_dir_open(fd, userPath ? path : NULL, traverseLeafLink, false);
9718 _user_read_attr(int fd, const char* userAttribute, off_t pos, void* userBuffer,
9731 int attr = attr_open(fd, NULL, attribute, O_RDONLY, false);
9743 _user_write_attr(int fd, const char* userAttribute, uint32 type, off_t pos,
9758 int attr = attr_create(fd, NULL, attribute, type,
9771 _user_stat_attr(int fd, const char* userAttribute,
9785 int attr = attr_open(fd, NULL, attribute, O_RDONLY, false);
9819 _user_open_attr(int fd, const char* userPath, const char* userName,
9845 return attr_create(fd, userPath ? path : NULL, name, type, openMode,
9849 return attr_open(fd, userPath ? path : NULL, name, openMode, false);
9854 _user_remove_attr(int fd, const char* userName)
9864 return attr_remove(fd, name, false);
9988 _user_setcwd(int fd, const char* userPath)
10006 return set_cwd(fd, userPath != NULL ? path : NULL, false);