1 /* SPDX-License-Identifier: LGPL-2.1 */
2 /*
3 *
4 * Copyright (c) International Business Machines Corp., 2002, 2007
5 * Author(s): Steve French (sfrench@us.ibm.com)
6 *
7 */
8
9 #ifndef _CIFSFS_H
10 #define _CIFSFS_H
11
12 #include <linux/hash.h>
13 #include <linux/dcache.h>
14
15 #define ROOT_I 2
16
17 extern atomic_t cifs_sillycounter;
18 extern atomic_t cifs_tmpcounter;
19
20 /*
21 * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down
22 * so that it will fit. We use hash_64 to convert the value to 31 bits, and
23 * then add 1, to ensure that we don't end up with a 0 as the value.
24 */
25 static inline ino_t
cifs_uniqueid_to_ino_t(u64 fileid)26 cifs_uniqueid_to_ino_t(u64 fileid)
27 {
28 if ((sizeof(ino_t)) < (sizeof(u64)))
29 return (ino_t)hash_64(fileid, (sizeof(ino_t) * 8) - 1) + 1;
30
31 return (ino_t)fileid;
32
33 }
34
cifs_set_time(struct dentry * dentry,unsigned long time)35 static inline void cifs_set_time(struct dentry *dentry, unsigned long time)
36 {
37 dentry->d_fsdata = (void *) time;
38 }
39
cifs_get_time(struct dentry * dentry)40 static inline unsigned long cifs_get_time(struct dentry *dentry)
41 {
42 return (unsigned long) dentry->d_fsdata;
43 }
44
45 extern struct file_system_type cifs_fs_type, smb3_fs_type;
46 extern const struct address_space_operations cifs_addr_ops;
47 extern const struct address_space_operations cifs_addr_ops_smallbuf;
48
49 /* Functions related to super block operations */
50 void cifs_sb_active(struct super_block *sb);
51 void cifs_sb_deactive(struct super_block *sb);
52
53 /* Functions related to inodes */
54 extern const struct inode_operations cifs_dir_inode_ops;
55 struct inode *cifs_root_iget(struct super_block *sb);
56 int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
57 struct dentry *direntry, umode_t mode);
58 int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
59 struct file *file, unsigned int oflags, umode_t mode);
60 int cifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
61 struct file *file, umode_t mode);
62 struct dentry *cifs_lookup(struct inode *parent_dir_inode,
63 struct dentry *direntry, unsigned int flags);
64 int cifs_unlink(struct inode *dir, struct dentry *dentry);
65 int cifs_hardlink(struct dentry *old_file, struct inode *inode,
66 struct dentry *direntry);
67 int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
68 struct dentry *direntry, umode_t mode, dev_t device_number);
69 struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
70 struct dentry *direntry, umode_t mode);
71 int cifs_rmdir(struct inode *inode, struct dentry *direntry);
72 int cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
73 struct dentry *source_dentry, struct inode *target_dir,
74 struct dentry *target_dentry, unsigned int flags);
75 int cifs_revalidate_file_attr(struct file *filp);
76 int cifs_revalidate_dentry_attr(struct dentry *dentry);
77 int cifs_revalidate_file(struct file *filp);
78 int cifs_revalidate_dentry(struct dentry *dentry);
79 int cifs_revalidate_mapping(struct inode *inode);
80 int cifs_zap_mapping(struct inode *inode);
81 int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
82 struct kstat *stat, u32 request_mask, unsigned int flags);
83 int cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
84 struct iattr *attrs);
85 int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
86 u64 len);
87
88 extern const struct inode_operations cifs_file_inode_ops;
89 extern const struct inode_operations cifs_symlink_inode_ops;
90 extern const struct inode_operations cifs_namespace_inode_operations;
91
92 struct file_kattr;
93 int cifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
94
95
96 /* Functions related to files and directories */
97 extern const struct netfs_request_ops cifs_req_ops;
98 extern const struct file_operations cifs_file_ops;
99 extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */
100 extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */
101 extern const struct file_operations cifs_file_nobrl_ops; /* no brlocks */
102 extern const struct file_operations cifs_file_direct_nobrl_ops;
103 extern const struct file_operations cifs_file_strict_nobrl_ops;
104 int cifs_open(struct inode *inode, struct file *file);
105 int cifs_close(struct inode *inode, struct file *file);
106 int cifs_closedir(struct inode *inode, struct file *file);
107 ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
108 ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
109 ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from);
110 ssize_t cifs_direct_write_iter(struct kiocb *iocb, struct iov_iter *from);
111 ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter);
112 int cifs_flock(struct file *file, int cmd, struct file_lock *fl);
113 int cifs_lock(struct file *file, int cmd, struct file_lock *flock);
114 int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
115 int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
116 int datasync);
117 int cifs_flush(struct file *file, fl_owner_t id);
118 int cifs_file_mmap_prepare(struct vm_area_desc *desc);
119 int cifs_file_strict_mmap_prepare(struct vm_area_desc *desc);
120 extern const struct file_operations cifs_dir_ops;
121 int cifs_readdir(struct file *file, struct dir_context *ctx);
122
123 /* Functions related to dir entries */
124 extern const struct dentry_operations cifs_dentry_ops;
125 extern const struct dentry_operations cifs_ci_dentry_ops;
126
127 struct vfsmount *cifs_d_automount(struct path *path);
128
129 /* Functions related to symlinks */
130 const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
131 struct delayed_call *done);
132 int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
133 struct dentry *direntry, const char *symname);
134
135 #ifdef CONFIG_CIFS_XATTR
136 extern const struct xattr_handler * const cifs_xattr_handlers[];
137 ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size);
138 #else
139 # define cifs_xattr_handlers NULL
140 # define cifs_listxattr NULL
141 #endif
142
143 ssize_t cifs_file_copychunk_range(unsigned int xid, struct file *src_file,
144 loff_t off, struct file *dst_file,
145 loff_t destoff, size_t len,
146 unsigned int flags);
147
148 long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg);
149 void cifs_setsize(struct inode *inode, loff_t offset);
150 void cifs_resize_file_locked(struct inode *inode, loff_t offset);
151
152 struct fs_context;
153 struct smb3_fs_context;
154 struct dentry *cifs_smb3_do_mount(struct fs_context *fc,
155 struct smb3_fs_context *old_ctx);
156
157 char *cifs_silly_fullpath(struct dentry *dentry);
158
159 #define CIFS_TMPNAME_PREFIX ".__smbfile_tmp"
160 #define CIFS_TMPNAME_LEN (DNAME_INLINE_LEN - 1)
161
162 #define CIFS_SILLYNAME_PREFIX ".__smbfile_silly"
163 #define CIFS_SILLYNAME_LEN (DNAME_INLINE_LEN - 1)
164
165 #ifdef CONFIG_CIFS_NFSD_EXPORT
166 extern const struct export_operations cifs_export_ops;
167 #endif /* CONFIG_CIFS_NFSD_EXPORT */
168
169 /* when changing internal version - update following two lines at same time */
170 #define SMB3_PRODUCT_BUILD 61
171 #define CIFS_VERSION "2.61"
172 #endif /* _CIFSFS_H */
173