Commit | Line | Data |
---|---|---|
f4415848 NJ |
1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
2 | /* | |
3 | * Copyright (C) 2016 Namjae Jeon <linkinjeon@kernel.org> | |
4 | * Copyright (C) 2018 Samsung Electronics Co., Ltd. | |
5 | */ | |
6 | ||
7 | #ifndef __KSMBD_VFS_H__ | |
8 | #define __KSMBD_VFS_H__ | |
9 | ||
10 | #include <linux/file.h> | |
11 | #include <linux/fs.h> | |
12 | #include <linux/namei.h> | |
13 | #include <uapi/linux/xattr.h> | |
14 | #include <linux/posix_acl.h> | |
dbab80e2 | 15 | #include <linux/unicode.h> |
f4415848 NJ |
16 | |
17 | #include "smbacl.h" | |
8b758859 | 18 | #include "xattr.h" |
f4415848 | 19 | |
ee2033e9 NJ |
20 | /* |
21 | * Enumeration for stream type. | |
22 | */ | |
23 | enum { | |
24 | DATA_STREAM = 1, /* type $DATA */ | |
25 | DIR_STREAM /* type $INDEX_ALLOCATION */ | |
26 | }; | |
27 | ||
f4415848 | 28 | /* CreateOptions */ |
f4415848 | 29 | #define CREATE_TREE_CONNECTION cpu_to_le32(0x00000080) |
f4415848 | 30 | #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000) |
f4415848 | 31 | |
f4415848 NJ |
32 | #define CREATE_OPTION_READONLY 0x10000000 |
33 | /* system. NB not sent over wire */ | |
34 | #define CREATE_OPTION_SPECIAL 0x20000000 | |
35 | ||
36 | struct ksmbd_work; | |
37 | struct ksmbd_file; | |
38 | struct ksmbd_conn; | |
39 | ||
40 | struct ksmbd_dir_info { | |
41 | const char *name; | |
42 | char *wptr; | |
43 | char *rptr; | |
44 | int name_len; | |
45 | int out_buf_len; | |
46 | int num_entry; | |
47 | int data_count; | |
48 | int last_entry_offset; | |
49 | bool hide_dot_file; | |
50 | int flags; | |
04e26094 | 51 | int last_entry_off_align; |
f4415848 NJ |
52 | }; |
53 | ||
54 | struct ksmbd_readdir_data { | |
55 | struct dir_context ctx; | |
56 | union { | |
57 | void *private; | |
58 | char *dirent; | |
59 | }; | |
60 | ||
61 | unsigned int used; | |
62 | unsigned int dirent_count; | |
63 | unsigned int file_attr; | |
dbab80e2 | 64 | struct unicode_map *um; |
f4415848 NJ |
65 | }; |
66 | ||
67 | /* ksmbd kstat wrapper to get valid create time when reading dir entry */ | |
68 | struct ksmbd_kstat { | |
69 | struct kstat *kstat; | |
70 | unsigned long long create_time; | |
71 | __le32 file_attributes; | |
72 | }; | |
73 | ||
da1e7ada CB |
74 | int ksmbd_vfs_lock_parent(struct user_namespace *user_ns, struct dentry *parent, |
75 | struct dentry *child); | |
af34983e HL |
76 | int ksmbd_vfs_may_delete(struct user_namespace *user_ns, struct dentry *dentry); |
77 | int ksmbd_vfs_query_maximal_access(struct user_namespace *user_ns, | |
78 | struct dentry *dentry, __le32 *daccess); | |
f4415848 NJ |
79 | int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode); |
80 | int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode); | |
81 | int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, | |
070fb21e | 82 | size_t count, loff_t *pos); |
f4415848 | 83 | int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp, |
070fb21e NJ |
84 | char *buf, size_t count, loff_t *pos, bool sync, |
85 | ssize_t *written); | |
64b39f4a | 86 | int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id); |
f4415848 NJ |
87 | int ksmbd_vfs_remove_file(struct ksmbd_work *work, char *name); |
88 | int ksmbd_vfs_link(struct ksmbd_work *work, | |
070fb21e | 89 | const char *oldname, const char *newname); |
c22180a5 | 90 | int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat); |
f4415848 | 91 | int ksmbd_vfs_fp_rename(struct ksmbd_work *work, struct ksmbd_file *fp, |
070fb21e | 92 | char *newname); |
265fd199 | 93 | int ksmbd_vfs_truncate(struct ksmbd_work *work, |
070fb21e | 94 | struct ksmbd_file *fp, loff_t size); |
f4415848 NJ |
95 | struct srv_copychunk; |
96 | int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work, | |
070fb21e NJ |
97 | struct ksmbd_file *src_fp, |
98 | struct ksmbd_file *dst_fp, | |
99 | struct srv_copychunk *chunks, | |
100 | unsigned int chunk_count, | |
101 | unsigned int *chunk_count_written, | |
102 | unsigned int *chunk_size_written, | |
103 | loff_t *total_size_written); | |
f4415848 | 104 | ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list); |
af34983e HL |
105 | ssize_t ksmbd_vfs_getxattr(struct user_namespace *user_ns, |
106 | struct dentry *dentry, | |
107 | char *xattr_name, | |
070fb21e | 108 | char **xattr_buf); |
af34983e HL |
109 | ssize_t ksmbd_vfs_casexattr_len(struct user_namespace *user_ns, |
110 | struct dentry *dentry, char *attr_name, | |
070fb21e | 111 | int attr_name_len); |
af34983e HL |
112 | int ksmbd_vfs_setxattr(struct user_namespace *user_ns, |
113 | struct dentry *dentry, const char *attr_name, | |
0c5fd887 | 114 | void *attr_value, size_t attr_size, int flags); |
64b39f4a | 115 | int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name, |
070fb21e | 116 | size_t *xattr_stream_name_size, int s_type); |
af34983e HL |
117 | int ksmbd_vfs_remove_xattr(struct user_namespace *user_ns, |
118 | struct dentry *dentry, char *attr_name); | |
265fd199 HL |
119 | int ksmbd_vfs_kern_path(struct ksmbd_work *work, |
120 | char *name, unsigned int flags, struct path *path, | |
070fb21e | 121 | bool caseless); |
265fd199 HL |
122 | struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work, |
123 | const char *name, | |
124 | unsigned int flags, | |
125 | struct path *path); | |
f4415848 NJ |
126 | int ksmbd_vfs_empty_dir(struct ksmbd_file *fp); |
127 | void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option); | |
64b39f4a | 128 | int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp, |
070fb21e | 129 | loff_t off, loff_t len); |
f4415848 NJ |
130 | struct file_allocated_range_buffer; |
131 | int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, | |
070fb21e | 132 | struct file_allocated_range_buffer *ranges, |
f7db8fd0 | 133 | unsigned int in_count, unsigned int *out_count); |
abf08576 CB |
134 | int ksmbd_vfs_unlink(struct mnt_idmap *idmap, struct dentry *dir, |
135 | struct dentry *dentry); | |
f4415848 | 136 | void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat); |
af34983e | 137 | int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work, |
b74d24f7 | 138 | struct mnt_idmap *idmap, |
af34983e | 139 | struct dentry *dentry, |
070fb21e | 140 | struct ksmbd_kstat *ksmbd_kstat); |
45a64e8b | 141 | void ksmbd_vfs_posix_lock_wait(struct file_lock *flock); |
f4415848 NJ |
142 | int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout); |
143 | void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock); | |
af34983e HL |
144 | int ksmbd_vfs_remove_acl_xattrs(struct user_namespace *user_ns, |
145 | struct dentry *dentry); | |
146 | int ksmbd_vfs_remove_sd_xattrs(struct user_namespace *user_ns, | |
147 | struct dentry *dentry); | |
148 | int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn, | |
149 | struct user_namespace *user_ns, | |
150 | struct dentry *dentry, | |
070fb21e | 151 | struct smb_ntsd *pntsd, int len); |
af34983e HL |
152 | int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn, |
153 | struct user_namespace *user_ns, | |
154 | struct dentry *dentry, | |
070fb21e | 155 | struct smb_ntsd **pntsd); |
af34983e HL |
156 | int ksmbd_vfs_set_dos_attrib_xattr(struct user_namespace *user_ns, |
157 | struct dentry *dentry, | |
070fb21e | 158 | struct xattr_dos_attrib *da); |
af34983e HL |
159 | int ksmbd_vfs_get_dos_attrib_xattr(struct user_namespace *user_ns, |
160 | struct dentry *dentry, | |
070fb21e | 161 | struct xattr_dos_attrib *da); |
af34983e | 162 | int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns, |
138060ba | 163 | struct dentry *dentry); |
af34983e | 164 | int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns, |
138060ba | 165 | struct dentry *dentry, |
070fb21e | 166 | struct inode *parent_inode); |
f4415848 | 167 | #endif /* __KSMBD_VFS_H__ */ |