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