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(const 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(const 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(const struct mnt_idmap *idmap, struct inode *inode, 68 struct dentry *direntry, umode_t mode, dev_t device_number); 69 struct dentry *cifs_mkdir(const 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(const 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(const struct mnt_idmap *idmap, const struct path *path, 82 struct kstat *stat, u32 request_mask, unsigned int flags); 83 int cifs_setattr(const 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 int cifs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry, 95 struct file_kattr *fa); 96 97 98 /* Functions related to files and directories */ 99 extern const struct netfs_request_ops cifs_req_ops; 100 extern const struct file_operations cifs_file_ops; 101 extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */ 102 extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */ 103 extern const struct file_operations cifs_file_nobrl_ops; /* no brlocks */ 104 extern const struct file_operations cifs_file_direct_nobrl_ops; 105 extern const struct file_operations cifs_file_strict_nobrl_ops; 106 int cifs_open(struct inode *inode, struct file *file); 107 int cifs_close(struct inode *inode, struct file *file); 108 int cifs_closedir(struct inode *inode, struct file *file); 109 ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to); 110 ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from); 111 ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from); 112 ssize_t cifs_direct_write_iter(struct kiocb *iocb, struct iov_iter *from); 113 ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter); 114 int cifs_flock(struct file *file, int cmd, struct file_lock *fl); 115 int cifs_lock(struct file *file, int cmd, struct file_lock *flock); 116 int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync); 117 int cifs_strict_fsync(struct file *file, loff_t start, loff_t end, 118 int datasync); 119 int cifs_flush(struct file *file, fl_owner_t id); 120 int cifs_file_mmap_prepare(struct vm_area_desc *desc); 121 int cifs_file_strict_mmap_prepare(struct vm_area_desc *desc); 122 extern const struct file_operations cifs_dir_ops; 123 int cifs_readdir(struct file *file, struct dir_context *ctx); 124 125 /* Functions related to dir entries */ 126 extern const struct dentry_operations cifs_dentry_ops; 127 extern const struct dentry_operations cifs_ci_dentry_ops; 128 129 struct vfsmount *cifs_d_automount(struct path *path); 130 131 /* Functions related to symlinks */ 132 const char *cifs_get_link(struct dentry *dentry, struct inode *inode, 133 struct delayed_call *done); 134 int cifs_symlink(const struct mnt_idmap *idmap, struct inode *inode, 135 struct dentry *direntry, const char *symname); 136 137 #ifdef CONFIG_CIFS_XATTR 138 extern const struct xattr_handler * const cifs_xattr_handlers[]; 139 ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size); 140 #else 141 # define cifs_xattr_handlers NULL 142 # define cifs_listxattr NULL 143 #endif 144 145 ssize_t cifs_file_copychunk_range(unsigned int xid, struct file *src_file, 146 loff_t off, struct file *dst_file, 147 loff_t destoff, size_t len, 148 unsigned int flags); 149 150 long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg); 151 void cifs_setsize(struct inode *inode, loff_t old_size, loff_t offset); 152 void cifs_resize_file_locked(struct inode *inode, loff_t old_size, 153 loff_t offset); 154 155 struct fs_context; 156 struct smb3_fs_context; 157 struct dentry *cifs_smb3_do_mount(struct fs_context *fc, 158 struct smb3_fs_context *old_ctx); 159 160 char *cifs_silly_fullpath(struct dentry *dentry); 161 162 #define CIFS_TMPNAME_PREFIX ".__smbfile_tmp" 163 #define CIFS_TMPNAME_LEN (DNAME_INLINE_LEN - 1) 164 165 #define CIFS_SILLYNAME_PREFIX ".__smbfile_silly" 166 #define CIFS_SILLYNAME_LEN (DNAME_INLINE_LEN - 1) 167 168 #ifdef CONFIG_CIFS_NFSD_EXPORT 169 extern const struct export_operations cifs_export_ops; 170 #endif /* CONFIG_CIFS_NFSD_EXPORT */ 171 172 #endif /* _CIFSFS_H */ 173