1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2016 Namjae Jeon <linkinjeon@kernel.org>
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
7 #ifndef __KSMBD_VFS_H__
8 #define __KSMBD_VFS_H__
10 #include <linux/file.h>
12 #include <linux/namei.h>
13 #include <uapi/linux/xattr.h>
14 #include <linux/posix_acl.h>
15 #include <linux/unicode.h>
21 * Enumeration for stream type.
24 DATA_STREAM = 1, /* type $DATA */
25 DIR_STREAM /* type $INDEX_ALLOCATION */
29 #define CREATE_TREE_CONNECTION cpu_to_le32(0x00000080)
30 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
32 #define CREATE_OPTION_READONLY 0x10000000
33 /* system. NB not sent over wire */
34 #define CREATE_OPTION_SPECIAL 0x20000000
40 struct ksmbd_dir_info {
48 int last_entry_offset;
51 int last_entry_off_align;
54 struct ksmbd_readdir_data {
55 struct dir_context ctx;
62 unsigned int dirent_count;
63 unsigned int file_attr;
64 struct unicode_map *um;
67 /* ksmbd kstat wrapper to get valid create time when reading dir entry */
70 unsigned long long create_time;
71 __le32 file_attributes;
74 int ksmbd_vfs_lock_parent(struct dentry *parent, struct dentry *child);
75 void ksmbd_vfs_query_maximal_access(struct user_namespace *user_ns,
76 struct dentry *dentry, __le32 *daccess);
77 int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode);
78 int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode);
79 int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
80 loff_t *pos, char *rbuf);
81 int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
82 char *buf, size_t count, loff_t *pos, bool sync,
84 int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id);
85 int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path);
86 int ksmbd_vfs_link(struct ksmbd_work *work,
87 const char *oldname, const char *newname);
88 int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat);
89 int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
90 char *newname, int flags);
91 int ksmbd_vfs_truncate(struct ksmbd_work *work,
92 struct ksmbd_file *fp, loff_t size);
94 int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
95 struct ksmbd_file *src_fp,
96 struct ksmbd_file *dst_fp,
97 struct srv_copychunk *chunks,
98 unsigned int chunk_count,
99 unsigned int *chunk_count_written,
100 unsigned int *chunk_size_written,
101 loff_t *total_size_written);
102 ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);
103 ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns,
104 struct dentry *dentry,
107 ssize_t ksmbd_vfs_casexattr_len(struct user_namespace *user_ns,
108 struct dentry *dentry, char *attr_name,
110 int ksmbd_vfs_setxattr(struct user_namespace *user_ns,
111 const struct path *path, const char *attr_name,
112 void *attr_value, size_t attr_size, int flags,
114 int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
115 size_t *xattr_stream_name_size, int s_type);
116 int ksmbd_vfs_remove_xattr(struct user_namespace *user_ns,
117 const struct path *path, char *attr_name);
118 int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
119 unsigned int flags, struct path *parent_path,
120 struct path *path, bool caseless);
121 void ksmbd_vfs_kern_path_unlock(struct path *parent_path, struct path *path);
122 struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
126 int ksmbd_vfs_empty_dir(struct ksmbd_file *fp);
127 void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option);
128 int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,
129 loff_t off, loff_t len);
130 struct file_allocated_range_buffer;
131 int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
132 struct file_allocated_range_buffer *ranges,
133 unsigned int in_count, unsigned int *out_count);
134 int ksmbd_vfs_unlink(struct file *filp);
135 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);
136 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
137 struct user_namespace *user_ns,
138 struct dentry *dentry,
139 struct ksmbd_kstat *ksmbd_kstat);
140 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
141 int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout);
142 void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
143 int ksmbd_vfs_remove_acl_xattrs(struct user_namespace *user_ns,
144 const struct path *path);
145 int ksmbd_vfs_remove_sd_xattrs(struct user_namespace *user_ns, const struct path *path);
146 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
147 struct user_namespace *user_ns,
148 const struct path *path,
149 struct smb_ntsd *pntsd, int len,
151 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
152 struct user_namespace *user_ns,
153 struct dentry *dentry,
154 struct smb_ntsd **pntsd);
155 int ksmbd_vfs_set_dos_attrib_xattr(struct user_namespace *user_ns,
156 const struct path *path,
157 struct xattr_dos_attrib *da,
159 int ksmbd_vfs_get_dos_attrib_xattr(struct user_namespace *user_ns,
160 struct dentry *dentry,
161 struct xattr_dos_attrib *da);
162 int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns,
164 int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns,
166 struct inode *parent_inode);
167 #endif /* __KSMBD_VFS_H__ */