Lines Matching defs:fd

40 #include <fd.h>
329 static status_t common_path_read_stat(int fd, char* path, bool traverseLeafLink,
337 static status_t fd_and_path_to_vnode(int fd, char* path, bool traverseLeafLink,
503 FDCloser(int fd, bool kernel) : fFD(fd), fKernel(kernel) {}
510 void SetTo(int fd, bool kernel)
513 fFD = fd;
530 int fd = fFD;
532 return fd;
2372 \a path must be given in either case. \a fd might be omitted, in which
2375 of the directory referred to by \a fd. If \a path is absolute \a fd is
2381 \param fd The FD. May be < 0.
2394 fd_and_path_to_dir_vnode(int fd, char* path, struct vnode** _vnode,
2401 if (fd < 0)
2408 return fd_and_path_to_vnode(fd, path, true, _vnode, NULL, kernel);
2713 get_fd_and_vnode(int fd, struct vnode** _vnode, bool kernel)
2716 = get_fd(get_current_io_context(kernel), fd);
2735 get_vnode_from_fd(int fd, bool kernel)
2740 descriptor = get_fd(get_current_io_context(kernel), fd);
2753 /*! Gets the vnode from an FD + path combination. If \a fd is lower than zero,
2756 If \a fd is a valid file descriptor, \a path may be NULL for directories,
2760 fd_and_path_to_vnode(int fd, char* path, bool traverseLeafLink,
2763 if (fd < 0 && !path)
2769 if (fd < 0 || (path != NULL && path[0] == '/')) {
2775 struct vnode* vnode = get_vnode_from_fd(fd, kernel);
2799 int fd;
2848 fd = new_fd(context, descriptor);
2849 if (fd < 0) {
2855 fd_set_close_on_exec(context, fd, (openMode & O_CLOEXEC) != 0);
2858 return fd;
3357 struct file_descriptor* fd = context->fds[i];
3358 if (fd == NULL)
3363 fd->type, fd->ops, fd->ref_count, fd->open_count, fd->open_mode,
3364 fd->pos, fd->cookie,
3365 fd->type >= FDTYPE_INDEX && fd->type <= FDTYPE_QUERY
3367 fd->u.vnode);
3893 read_pages(int fd, off_t pos, const iovec* vecs, size_t count,
3899 descriptor = get_fd_and_vnode(fd, &vnode, true);
3912 write_pages(int fd, off_t pos, const iovec* vecs, size_t count,
3918 descriptor = get_fd_and_vnode(fd, &vnode, true);
3932 read_file_io_vec_pages(int fd, const file_io_vec* fileVecs, size_t fileVecCount,
3939 descriptor = get_fd_and_vnode(fd, &vnode, true);
3953 write_file_io_vec_pages(int fd, const file_io_vec* fileVecs, size_t fileVecCount,
3960 descriptor = get_fd_and_vnode(fd, &vnode, true);
4025 vfs_get_cookie_from_fd(int fd, void** _cookie)
4029 descriptor = get_fd(get_current_io_context(true), fd);
4039 vfs_get_vnode_from_fd(int fd, bool kernel, struct vnode** vnode)
4041 *vnode = get_vnode_from_fd(fd, kernel);
4196 vfs_read_stat(int fd, const char* path, bool traverseLeafLink,
4202 // path given: get the stat of the node referred to by (fd, path)
4207 status = common_path_read_stat(fd, pathBuffer.LockBuffer(),
4212 = get_fd(get_current_io_context(kernel), fd);
5189 int fd = get_new_fd(FDTYPE_FILE, NULL, vnode, cookie, openMode, kernel);
5190 if (fd < 0) {
5194 return fd;
5255 int fd = open_vnode(vnode, openMode & ~O_CREAT, kernel);
5257 if (fd >= 0)
5260 return fd;
5291 int fd = get_new_fd(FDTYPE_FILE, NULL, vnode, cookie, openMode, kernel);
5292 if (fd >= 0)
5293 return fd;
5295 status = fd;
5320 // directory is opened, create a fd
5347 // directory is opened, create a fd
5381 file_create(int fd, char* path, int openMode, int perms, bool kernel)
5389 status_t status = fd_and_path_to_dir_vnode(fd, path, &directory, name,
5438 file_open(int fd, char* path, int openMode, bool kernel)
5442 FUNCTION(("file_open: fd: %d, entry path = '%s', omode %d, kernel %d\n",
5443 fd, path, openMode, kernel));
5448 status_t status = fd_and_path_to_vnode(fd, path, traverse, &vnode,
5654 dir_create(int fd, char* path, int perms, bool kernel)
5663 status = fd_and_path_to_dir_vnode(fd, path, &vnode, filename, kernel);
5709 dir_open(int fd, char* path, bool kernel)
5711 FUNCTION(("dir_open: fd: %d, entry path = '%s', kernel %d\n", fd, path,
5717 status_t status = fd_and_path_to_vnode(fd, path, true, &vnode, &parentID,
5861 dir_remove(int fd, char* path, bool kernel)
5892 status = fd_and_path_to_dir_vnode(fd, path, &directory, name, kernel);
5920 common_fcntl(int fd, int op, size_t argument, bool kernel)
5924 FUNCTION(("common_fcntl(fd = %d, op = %d, argument = %lx, %s)\n",
5925 fd, op, argument, kernel ? "kernel" : "user"));
5928 fd);
5957 fd_set_close_on_exec(context, fd, (argument & FD_CLOEXEC) != 0);
5970 status = fd_close_on_exec(context, fd) ? FD_CLOEXEC : 0;
6008 fd_set_close_on_exec(context, fd, false);
6064 common_sync(int fd, bool kernel)
6070 FUNCTION(("common_fsync: entry. fd %d kernel %d\n", fd, kernel));
6072 descriptor = get_fd_and_vnode(fd, &vnode, kernel);
6087 common_lock_node(int fd, bool kernel)
6092 descriptor = get_fd_and_vnode(fd, &vnode, kernel);
6110 common_unlock_node(int fd, bool kernel)
6115 descriptor = get_fd_and_vnode(fd, &vnode, kernel);
6133 common_read_link(int fd, char* path, char* buffer, size_t* _bufferSize,
6139 status = fd_and_path_to_vnode(fd, path, false, &vnode, NULL, kernel);
6154 common_create_symlink(int fd, char* path, const char* toPath, int mode,
6162 FUNCTION(("common_create_symlink(fd = %d, path = %s, toPath = %s, "
6163 "mode = %d, kernel = %d)\n", fd, path, toPath, mode, kernel));
6165 status = fd_and_path_to_dir_vnode(fd, path, &vnode, name, kernel);
6224 common_unlink(int fd, char* path, bool kernel)
6230 FUNCTION(("common_unlink: fd: %d, path '%s', kernel %d\n", fd, path,
6233 status = fd_and_path_to_dir_vnode(fd, path, &vnode, filename, kernel);
6249 common_access(int fd, char* path, int mode, bool effectiveUserGroup, bool kernel)
6256 status = fd_and_path_to_vnode(fd, path, true, &vnode, NULL, kernel);
6272 common_rename(int fd, char* path, int newFD, char* newPath, bool kernel)
6280 FUNCTION(("common_rename(fd = %d, path = %s, newFD = %d, newPath = %s, "
6281 "kernel = %d)\n", fd, path, newFD, newPath, kernel));
6283 status = fd_and_path_to_dir_vnode(fd, path, &fromVnode, fromName, kernel);
6361 common_path_read_stat(int fd, char* path, bool traverseLeafLink,
6364 FUNCTION(("common_path_read_stat: fd: %d, path '%s', stat %p,\n", fd, path,
6368 status_t status = fd_and_path_to_vnode(fd, path, traverseLeafLink, &vnode,
6388 common_path_write_stat(int fd, char* path, bool traverseLeafLink,
6391 FUNCTION(("common_write_stat: fd: %d, path '%s', stat %p, stat_mask %d, "
6392 "kernel %d\n", fd, path, stat, statMask, kernel));
6395 status_t status = fd_and_path_to_vnode(fd, path, traverseLeafLink, &vnode,
6412 attr_dir_open(int fd, char* path, bool traverseLeafLink, bool kernel)
6414 FUNCTION(("attr_dir_open(fd = %d, path = '%s', kernel = %d)\n", fd, path,
6418 status_t status = fd_and_path_to_vnode(fd, path, traverseLeafLink, &vnode,
6488 attr_create(int fd, char* path, const char* name, uint32 type,
6496 status_t status = fd_and_path_to_vnode(fd, path, traverse, &vnode, NULL,
6516 fd = get_new_fd(FDTYPE_ATTR, NULL, vnode, cookie, openMode, kernel);
6517 if (fd >= 0)
6518 return fd;
6520 status = fd;
6535 attr_open(int fd, char* path, const char* name, int openMode, bool kernel)
6542 status_t status = fd_and_path_to_vnode(fd, path, traverse, &vnode, NULL,
6563 fd = get_new_fd(FDTYPE_ATTR, NULL, vnode, cookie, openMode, kernel);
6564 if (fd >= 0)
6565 return fd;
6567 status = fd;
6708 attr_remove(int fd, const char* name, bool kernel)
6717 FUNCTION(("attr_remove: fd = %d, name = \"%s\", kernel %d\n", fd, name,
6720 descriptor = get_fd_and_vnode(fd, &vnode, kernel);
6749 FUNCTION(("attr_rename: from fd = %d, from name = \"%s\", to fd = %d, to "
6803 // get fd for the index directory
6804 int fd;
6805 fd = get_new_fd(FDTYPE_INDEX_DIR, mount, NULL, cookie, O_CLOEXEC, kernel);
6806 if (fd >= 0)
6807 return fd;
6813 status = fd;
7006 // get fd for the index directory
7007 int fd;
7008 fd = get_new_fd(FDTYPE_QUERY, mount, NULL, cookie, O_CLOEXEC, kernel);
7009 if (fd >= 0)
7010 return fd;
7012 status = fd;
7797 fs_read_attr(int fd, const char *attribute, uint32 type, off_t pos,
7800 int attrFD = attr_open(fd, NULL, attribute, O_RDONLY, true);
7840 set_cwd(int fd, char* path, bool kernel)
7850 status = fd_and_path_to_vnode(fd, path, true, &vnode, NULL, kernel);
8012 At least one of \a fd and \a path must be specified.
8013 If only \a fd is given, the function opens the node identified by this
8015 the path is absolute, \a fd is ignored; a relative path is reckoned off
8016 of the directory (!) identified by \a fd.
8018 \param fd The FD. May be < 0.
8025 _kern_open(int fd, const char* path, int openMode, int perms)
8032 return file_create(fd, pathBuffer.LockBuffer(), openMode, perms, true);
8034 return file_open(fd, pathBuffer.LockBuffer(), openMode, true);
8065 At least one of \a fd and \a path must be specified.
8066 If only \a fd is given, the function opens the directory identified by this
8068 the path is absolute, \a fd is ignored; a relative path is reckoned off
8069 of the directory (!) identified by \a fd.
8071 \param fd The FD. May be < 0.
8077 _kern_open_dir(int fd, const char* path)
8083 return dir_open(fd, pathBuffer.LockBuffer(), true);
8088 _kern_fcntl(int fd, int op, size_t argument)
8090 return common_fcntl(fd, op, argument, true);
8095 _kern_fsync(int fd)
8097 return common_sync(fd, true);
8102 _kern_lock_node(int fd)
8104 return common_lock_node(fd, true);
8109 _kern_unlock_node(int fd)
8111 return common_unlock_node(fd, true);
8127 which the directory shall be created. If both \a fd and \a path are given
8128 and the path is absolute, \a fd is ignored; a relative path is reckoned off
8129 of the directory (!) identified by \a fd.
8131 \param fd The FD. May be < 0.
8138 _kern_create_dir(int fd, const char* path, int perms)
8144 return dir_create(fd, pathBuffer.LockBuffer(), perms, true);
8149 _kern_remove_dir(int fd, const char* path)
8156 return dir_remove(fd, pathBuffer.LockBuffer(), true);
8159 return dir_remove(fd, NULL, true);
8165 At least one of \a fd and \a path must be specified.
8166 If only \a fd is given, the function the symlink to be read is the node
8168 symlink to be read. If both are given and the path is absolute, \a fd is
8170 by \a fd.
8174 \param fd The FD. May be < 0.
8182 _kern_read_link(int fd, const char* path, char* buffer, size_t* _bufferSize)
8189 return common_read_link(fd, pathBuffer.LockBuffer(),
8193 return common_read_link(fd, NULL, buffer, _bufferSize, true);
8201 which the symlink shall be created. If both \a fd and \a path are given and
8202 the path is absolute, \a fd is ignored; a relative path is reckoned off
8203 of the directory (!) identified by \a fd.
8205 \param fd The FD. May be < 0.
8212 _kern_create_symlink(int fd, const char* path, const char* toPath, int mode)
8218 return common_create_symlink(fd, pathBuffer.LockBuffer(),
8241 directly. If both \a fd and \a path are given and the path is absolute,
8242 \a fd is ignored; a relative path is reckoned off of the directory (!)
8243 identified by \a fd.
8245 \param fd The FD. May be < 0.
8251 _kern_unlink(int fd, const char* path)
8257 return common_unlink(fd, pathBuffer.LockBuffer(), true);
8293 _kern_access(int fd, const char* path, int mode, bool effectiveUserGroup)
8299 return common_access(fd, pathBuffer.LockBuffer(), mode, effectiveUserGroup,
8306 If only \a fd is given, the stat operation associated with the type
8309 stat data. If both \a fd and \a path are given and the path is absolute,
8310 \a fd is ignored; a relative path is reckoned off of the directory (!)
8311 identified by \a fd and specifies the entry whose stat data shall be
8314 \param fd The FD. May be < 0.
8324 _kern_read_stat(int fd, const char* path, bool traverseLeafLink,
8340 status = vfs_read_stat(fd, path, traverseLeafLink, stat, true);
8351 If only \a fd is given, the stat operation associated with the type
8354 stat data. If both \a fd and \a path are given and the path is absolute,
8355 \a fd is ignored; a relative path is reckoned off of the directory (!)
8356 identified by \a fd and specifies the entry whose stat data shall be
8359 \param fd The FD. May be < 0.
8371 _kern_write_stat(int fd, const char* path, bool traverseLeafLink,
8390 // path given: write the stat of the node referred to by (fd, path)
8395 status = common_path_write_stat(fd, pathBuffer.LockBuffer(),
8400 = get_fd(get_current_io_context(true), fd);
8417 _kern_open_attr_dir(int fd, const char* path, bool traverseLeafLink)
8426 return attr_dir_open(fd, path ? pathBuffer.LockBuffer() : NULL,
8432 _kern_open_attr(int fd, const char* path, const char* name, uint32 type,
8440 return attr_create(fd, pathBuffer.LockBuffer(), name, type, openMode,
8444 return attr_open(fd, pathBuffer.LockBuffer(), name, openMode, true);
8449 _kern_remove_attr(int fd, const char* name)
8451 return attr_remove(fd, name, true);
8502 _kern_setcwd(int fd, const char* path)
8511 return set_cwd(fd, path != NULL ? pathBuffer.LockBuffer() : NULL, true);
8786 _user_open(int fd, const char* userPath, int openMode, int perms)
8799 return file_create(fd, buffer, openMode, perms, false);
8801 return file_open(fd, buffer, openMode, false);
8822 _user_open_dir(int fd, const char* userPath)
8825 return dir_open(fd, NULL, false);
8837 return dir_open(fd, buffer, false);
8845 equivalent to \code _user_open_dir(fd, "..") \endcode. It really is
8851 \param fd A FD referring to a directory.
8859 _user_open_parent_dir(int fd, char* userName, size_t nameLength)
8867 int parentFD = dir_open(fd, (char*)"..", kernel);
8875 struct vnode* dirVNode = get_vnode_from_fd(fd, kernel);
8902 _user_fcntl(int fd, int op, size_t argument)
8904 status_t status = common_fcntl(fd, op, argument, false);
8913 _user_fsync(int fd)
8915 return common_sync(fd, false);
8920 _user_flock(int fd, int operation)
8922 FUNCTION(("_user_fcntl(fd = %d, op = %d)\n", fd, operation));
8937 descriptor = get_fd_and_vnode(fd, &vnode, false);
8969 _user_lock_node(int fd)
8971 return common_lock_node(fd, false);
8976 _user_unlock_node(int fd)
8978 return common_unlock_node(fd, false);
9001 _user_create_dir(int fd, const char* userPath, int perms)
9013 return dir_create(fd, path, perms, false);
9018 _user_remove_dir(int fd, const char* userPath)
9032 return dir_remove(fd, userPath ? path : NULL, false);
9037 _user_read_link(int fd, const char* userPath, char* userBuffer,
9062 status_t status = common_read_link(fd, userPath ? path : NULL, buffer,
9081 _user_create_symlink(int fd, const char* userPath, const char* userToPath,
9098 return common_create_symlink(fd, path, toPath, mode, false);
9130 _user_unlink(int fd, const char* userPath)
9142 return common_unlink(fd, path, false);
9168 _user_create_fifo(int fd, const char* userPath, mode_t perms)
9184 status_t status = fd_and_path_to_dir_vnode(fd, path, &dir, filename, false);
9263 _user_access(int fd, const char* userPath, int mode, bool effectiveUserGroup)
9275 return common_access(fd, path, mode, effectiveUserGroup, false);
9280 _user_read_stat(int fd, const char* userPath, bool traverseLink,
9293 // path given: get the stat of the node referred to by (fd, path)
9309 status = common_path_read_stat(fd, path, traverseLink, &stat, false);
9313 = get_fd(get_current_io_context(false), fd);
9333 _user_write_stat(int fd, const char* userPath, bool traverseLeafLink,
9352 // path given: write the stat of the node referred to by (fd, path)
9368 status = common_path_write_stat(fd, path, traverseLeafLink, &stat,
9373 = get_fd(get_current_io_context(false), fd);
9391 _user_open_attr_dir(int fd, const char* userPath, bool traverseLeafLink)
9405 return attr_dir_open(fd, userPath ? path : NULL, traverseLeafLink, false);
9410 _user_read_attr(int fd, const char* attribute, off_t pos, void* userBuffer,
9413 int attr = attr_open(fd, NULL, attribute, O_RDONLY, false);
9425 _user_write_attr(int fd, const char* attribute, uint32 type, off_t pos,
9430 int attr = attr_create(fd, NULL, attribute, type,
9443 _user_stat_attr(int fd, const char* attribute, struct attr_info* userAttrInfo)
9445 int attr = attr_open(fd, NULL, attribute, O_RDONLY, false);
9480 _user_open_attr(int fd, const char* userPath, const char* userName,
9502 return attr_create(fd, userPath ? path : NULL, name, type, openMode,
9506 return attr_open(fd, userPath ? path : NULL, name, openMode, false);
9511 _user_remove_attr(int fd, const char* userName)
9519 return attr_remove(fd, name, false);
9635 _user_setcwd(int fd, const char* userPath)
9651 return set_cwd(fd, userPath != NULL ? path : NULL, false);
9715 int fd = query_open(device, query, flags, port, token, false);
9718 return fd;