xref: /linux/fs/smb/client/cifsfs.h (revision cf1b04aaef8b83f668fac10bfc4d4d76ba6e6fa1)
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
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 
35 static inline void cifs_set_time(struct dentry *dentry, unsigned long time)
36 {
37 	dentry->d_fsdata = (void *) time;
38 }
39 
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, bool excl);
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 
93 /* Functions related to files and directories */
94 extern const struct netfs_request_ops cifs_req_ops;
95 extern const struct file_operations cifs_file_ops;
96 extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */
97 extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */
98 extern const struct file_operations cifs_file_nobrl_ops; /* no brlocks */
99 extern const struct file_operations cifs_file_direct_nobrl_ops;
100 extern const struct file_operations cifs_file_strict_nobrl_ops;
101 int cifs_open(struct inode *inode, struct file *file);
102 int cifs_close(struct inode *inode, struct file *file);
103 int cifs_closedir(struct inode *inode, struct file *file);
104 ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
105 ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
106 ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from);
107 ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter);
108 int cifs_flock(struct file *file, int cmd, struct file_lock *fl);
109 int cifs_lock(struct file *file, int cmd, struct file_lock *flock);
110 int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
111 int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
112 		      int datasync);
113 int cifs_flush(struct file *file, fl_owner_t id);
114 int cifs_file_mmap_prepare(struct vm_area_desc *desc);
115 int cifs_file_strict_mmap_prepare(struct vm_area_desc *desc);
116 extern const struct file_operations cifs_dir_ops;
117 int cifs_readdir(struct file *file, struct dir_context *ctx);
118 
119 /* Functions related to dir entries */
120 extern const struct dentry_operations cifs_dentry_ops;
121 extern const struct dentry_operations cifs_ci_dentry_ops;
122 
123 struct vfsmount *cifs_d_automount(struct path *path);
124 
125 /* Functions related to symlinks */
126 const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
127 			  struct delayed_call *done);
128 int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
129 		 struct dentry *direntry, const char *symname);
130 
131 #ifdef CONFIG_CIFS_XATTR
132 extern const struct xattr_handler * const cifs_xattr_handlers[];
133 ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size);
134 #else
135 # define cifs_xattr_handlers NULL
136 # define cifs_listxattr NULL
137 #endif
138 
139 ssize_t cifs_file_copychunk_range(unsigned int xid, struct file *src_file,
140 				  loff_t off, struct file *dst_file,
141 				  loff_t destoff, size_t len,
142 				  unsigned int flags);
143 
144 long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg);
145 void cifs_setsize(struct inode *inode, loff_t offset);
146 
147 struct smb3_fs_context;
148 struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type, int flags,
149 				  struct smb3_fs_context *old_ctx);
150 
151 char *cifs_silly_fullpath(struct dentry *dentry);
152 
153 #define CIFS_TMPNAME_PREFIX	".__smbfile_tmp"
154 #define CIFS_TMPNAME_LEN	(DNAME_INLINE_LEN - 1)
155 
156 #define CIFS_SILLYNAME_PREFIX	".__smbfile_silly"
157 #define CIFS_SILLYNAME_LEN	(DNAME_INLINE_LEN - 1)
158 
159 #ifdef CONFIG_CIFS_NFSD_EXPORT
160 extern const struct export_operations cifs_export_ops;
161 #endif /* CONFIG_CIFS_NFSD_EXPORT */
162 
163 /* when changing internal version - update following two lines at same time */
164 #define SMB3_PRODUCT_BUILD 60
165 #define CIFS_VERSION   "2.60"
166 #endif				/* _CIFSFS_H */
167