198d91704SNamjae Jeon // SPDX-License-Identifier: GPL-2.0-or-later 298d91704SNamjae Jeon /* 398d91704SNamjae Jeon * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd. 498d91704SNamjae Jeon */ 598d91704SNamjae Jeon 698d91704SNamjae Jeon #include <linux/slab.h> 7654762dfSHyeongseok Kim #include <linux/compat.h> 898d91704SNamjae Jeon #include <linux/cred.h> 998d91704SNamjae Jeon #include <linux/buffer_head.h> 105267456eSSungjong Seo #include <linux/blkdev.h> 1198d91704SNamjae Jeon 1298d91704SNamjae Jeon #include "exfat_raw.h" 1398d91704SNamjae Jeon #include "exfat_fs.h" 1498d91704SNamjae Jeon 1598d91704SNamjae Jeon static int exfat_cont_expand(struct inode *inode, loff_t size) 1698d91704SNamjae Jeon { 1798d91704SNamjae Jeon struct address_space *mapping = inode->i_mapping; 1898d91704SNamjae Jeon loff_t start = i_size_read(inode), count = size - i_size_read(inode); 1998d91704SNamjae Jeon int err, err2; 2098d91704SNamjae Jeon 2198d91704SNamjae Jeon err = generic_cont_expand_simple(inode, size); 2298d91704SNamjae Jeon if (err) 2398d91704SNamjae Jeon return err; 2498d91704SNamjae Jeon 2598d91704SNamjae Jeon inode->i_ctime = inode->i_mtime = current_time(inode); 2698d91704SNamjae Jeon mark_inode_dirty(inode); 2798d91704SNamjae Jeon 2898d91704SNamjae Jeon if (!IS_SYNC(inode)) 2998d91704SNamjae Jeon return 0; 3098d91704SNamjae Jeon 3198d91704SNamjae Jeon err = filemap_fdatawrite_range(mapping, start, start + count - 1); 3298d91704SNamjae Jeon err2 = sync_mapping_buffers(mapping); 3398d91704SNamjae Jeon if (!err) 3498d91704SNamjae Jeon err = err2; 3598d91704SNamjae Jeon err2 = write_inode_now(inode, 1); 3698d91704SNamjae Jeon if (!err) 3798d91704SNamjae Jeon err = err2; 3898d91704SNamjae Jeon if (err) 3998d91704SNamjae Jeon return err; 4098d91704SNamjae Jeon 4198d91704SNamjae Jeon return filemap_fdatawait_range(mapping, start, start + count - 1); 4298d91704SNamjae Jeon } 4398d91704SNamjae Jeon 4498d91704SNamjae Jeon static bool exfat_allow_set_time(struct exfat_sb_info *sbi, struct inode *inode) 4598d91704SNamjae Jeon { 4698d91704SNamjae Jeon mode_t allow_utime = sbi->options.allow_utime; 4798d91704SNamjae Jeon 4898d91704SNamjae Jeon if (!uid_eq(current_fsuid(), inode->i_uid)) { 4998d91704SNamjae Jeon if (in_group_p(inode->i_gid)) 5098d91704SNamjae Jeon allow_utime >>= 3; 5198d91704SNamjae Jeon if (allow_utime & MAY_WRITE) 5298d91704SNamjae Jeon return true; 5398d91704SNamjae Jeon } 5498d91704SNamjae Jeon 5598d91704SNamjae Jeon /* use a default check */ 5698d91704SNamjae Jeon return false; 5798d91704SNamjae Jeon } 5898d91704SNamjae Jeon 5998d91704SNamjae Jeon static int exfat_sanitize_mode(const struct exfat_sb_info *sbi, 6098d91704SNamjae Jeon struct inode *inode, umode_t *mode_ptr) 6198d91704SNamjae Jeon { 6298d91704SNamjae Jeon mode_t i_mode, mask, perm; 6398d91704SNamjae Jeon 6498d91704SNamjae Jeon i_mode = inode->i_mode; 6598d91704SNamjae Jeon 6698d91704SNamjae Jeon mask = (S_ISREG(i_mode) || S_ISLNK(i_mode)) ? 6798d91704SNamjae Jeon sbi->options.fs_fmask : sbi->options.fs_dmask; 6898d91704SNamjae Jeon perm = *mode_ptr & ~(S_IFMT | mask); 6998d91704SNamjae Jeon 7098d91704SNamjae Jeon /* Of the r and x bits, all (subject to umask) must be present.*/ 7198d91704SNamjae Jeon if ((perm & 0555) != (i_mode & 0555)) 7298d91704SNamjae Jeon return -EPERM; 7398d91704SNamjae Jeon 7498d91704SNamjae Jeon if (exfat_mode_can_hold_ro(inode)) { 7598d91704SNamjae Jeon /* 7698d91704SNamjae Jeon * Of the w bits, either all (subject to umask) or none must 7798d91704SNamjae Jeon * be present. 7898d91704SNamjae Jeon */ 7998d91704SNamjae Jeon if ((perm & 0222) && ((perm & 0222) != (0222 & ~mask))) 8098d91704SNamjae Jeon return -EPERM; 8198d91704SNamjae Jeon } else { 8298d91704SNamjae Jeon /* 8398d91704SNamjae Jeon * If exfat_mode_can_hold_ro(inode) is false, can't change 8498d91704SNamjae Jeon * w bits. 8598d91704SNamjae Jeon */ 8698d91704SNamjae Jeon if ((perm & 0222) != (0222 & ~mask)) 8798d91704SNamjae Jeon return -EPERM; 8898d91704SNamjae Jeon } 8998d91704SNamjae Jeon 9098d91704SNamjae Jeon *mode_ptr &= S_IFMT | perm; 9198d91704SNamjae Jeon 9298d91704SNamjae Jeon return 0; 9398d91704SNamjae Jeon } 9498d91704SNamjae Jeon 9598d91704SNamjae Jeon /* resize the file length */ 96*f7cde967SYuezhang Mo int __exfat_truncate(struct inode *inode) 9798d91704SNamjae Jeon { 9898d91704SNamjae Jeon unsigned int num_clusters_new, num_clusters_phys; 9998d91704SNamjae Jeon unsigned int last_clu = EXFAT_FREE_CLUSTER; 10098d91704SNamjae Jeon struct exfat_chain clu; 10198d91704SNamjae Jeon struct super_block *sb = inode->i_sb; 10298d91704SNamjae Jeon struct exfat_sb_info *sbi = EXFAT_SB(sb); 10398d91704SNamjae Jeon struct exfat_inode_info *ei = EXFAT_I(inode); 10498d91704SNamjae Jeon 10598d91704SNamjae Jeon /* check if the given file ID is opened */ 10698d91704SNamjae Jeon if (ei->type != TYPE_FILE && ei->type != TYPE_DIR) 10798d91704SNamjae Jeon return -EPERM; 10898d91704SNamjae Jeon 1097018ec68STetsuhiro Kohada exfat_set_volume_dirty(sb); 11098d91704SNamjae Jeon 11198d91704SNamjae Jeon num_clusters_new = EXFAT_B_TO_CLU_ROUND_UP(i_size_read(inode), sbi); 1127dee6f57SChristophe Vu-Brugier num_clusters_phys = EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi); 11398d91704SNamjae Jeon 11498d91704SNamjae Jeon exfat_chain_set(&clu, ei->start_clu, num_clusters_phys, ei->flags); 11598d91704SNamjae Jeon 116*f7cde967SYuezhang Mo if (i_size_read(inode) > 0) { 11798d91704SNamjae Jeon /* 11898d91704SNamjae Jeon * Truncate FAT chain num_clusters after the first cluster 11998d91704SNamjae Jeon * num_clusters = min(new, phys); 12098d91704SNamjae Jeon */ 12198d91704SNamjae Jeon unsigned int num_clusters = 12298d91704SNamjae Jeon min(num_clusters_new, num_clusters_phys); 12398d91704SNamjae Jeon 12498d91704SNamjae Jeon /* 12598d91704SNamjae Jeon * Follow FAT chain 12698d91704SNamjae Jeon * (defensive coding - works fine even with corrupted FAT table 12798d91704SNamjae Jeon */ 12898d91704SNamjae Jeon if (clu.flags == ALLOC_NO_FAT_CHAIN) { 12998d91704SNamjae Jeon clu.dir += num_clusters; 13098d91704SNamjae Jeon clu.size -= num_clusters; 13198d91704SNamjae Jeon } else { 13298d91704SNamjae Jeon while (num_clusters > 0) { 13398d91704SNamjae Jeon last_clu = clu.dir; 13498d91704SNamjae Jeon if (exfat_get_next_cluster(sb, &(clu.dir))) 13598d91704SNamjae Jeon return -EIO; 13698d91704SNamjae Jeon 13798d91704SNamjae Jeon num_clusters--; 13898d91704SNamjae Jeon clu.size--; 13998d91704SNamjae Jeon } 14098d91704SNamjae Jeon } 14198d91704SNamjae Jeon } else { 14298d91704SNamjae Jeon ei->flags = ALLOC_NO_FAT_CHAIN; 14398d91704SNamjae Jeon ei->start_clu = EXFAT_EOF_CLUSTER; 14498d91704SNamjae Jeon } 14598d91704SNamjae Jeon 14698d91704SNamjae Jeon if (ei->type == TYPE_FILE) 14798d91704SNamjae Jeon ei->attr |= ATTR_ARCHIVE; 14898d91704SNamjae Jeon 1494493895bSYuezhang Mo /* 1504493895bSYuezhang Mo * update the directory entry 1514493895bSYuezhang Mo * 1524493895bSYuezhang Mo * If the directory entry is updated by mark_inode_dirty(), the 1534493895bSYuezhang Mo * directory entry will be written after a writeback cycle of 1544493895bSYuezhang Mo * updating the bitmap/FAT, which may result in clusters being 1554493895bSYuezhang Mo * freed but referenced by the directory entry in the event of a 1564493895bSYuezhang Mo * sudden power failure. 1574493895bSYuezhang Mo * __exfat_write_inode() is called for directory entry, bitmap 1584493895bSYuezhang Mo * and FAT to be written in a same writeback. 1594493895bSYuezhang Mo */ 16023e6e1c9SYuezhang Mo if (__exfat_write_inode(inode, inode_needs_sync(inode))) 16198d91704SNamjae Jeon return -EIO; 16298d91704SNamjae Jeon 16398d91704SNamjae Jeon /* cut off from the FAT chain */ 16498d91704SNamjae Jeon if (ei->flags == ALLOC_FAT_CHAIN && last_clu != EXFAT_FREE_CLUSTER && 16598d91704SNamjae Jeon last_clu != EXFAT_EOF_CLUSTER) { 16698d91704SNamjae Jeon if (exfat_ent_set(sb, last_clu, EXFAT_EOF_CLUSTER)) 16798d91704SNamjae Jeon return -EIO; 16898d91704SNamjae Jeon } 16998d91704SNamjae Jeon 17098d91704SNamjae Jeon /* invalidate cache and free the clusters */ 17198d91704SNamjae Jeon /* clear exfat cache */ 17298d91704SNamjae Jeon exfat_cache_inval_inode(inode); 17398d91704SNamjae Jeon 17498d91704SNamjae Jeon /* hint information */ 17598d91704SNamjae Jeon ei->hint_bmap.off = EXFAT_EOF_CLUSTER; 17698d91704SNamjae Jeon ei->hint_bmap.clu = EXFAT_EOF_CLUSTER; 17798d91704SNamjae Jeon 17898d91704SNamjae Jeon /* hint_stat will be used if this is directory. */ 17998d91704SNamjae Jeon ei->hint_stat.eidx = 0; 18098d91704SNamjae Jeon ei->hint_stat.clu = ei->start_clu; 18198d91704SNamjae Jeon ei->hint_femp.eidx = EXFAT_HINT_NONE; 18298d91704SNamjae Jeon 18398d91704SNamjae Jeon /* free the clusters */ 18498d91704SNamjae Jeon if (exfat_free_cluster(inode, &clu)) 18598d91704SNamjae Jeon return -EIO; 18698d91704SNamjae Jeon 18798d91704SNamjae Jeon return 0; 18898d91704SNamjae Jeon } 18998d91704SNamjae Jeon 190e981917bSYuezhang Mo void exfat_truncate(struct inode *inode) 19198d91704SNamjae Jeon { 19298d91704SNamjae Jeon struct super_block *sb = inode->i_sb; 19398d91704SNamjae Jeon struct exfat_sb_info *sbi = EXFAT_SB(sb); 1947dee6f57SChristophe Vu-Brugier struct exfat_inode_info *ei = EXFAT_I(inode); 19545882a6aSXianting Tian unsigned int blocksize = i_blocksize(inode); 19698d91704SNamjae Jeon loff_t aligned_size; 19798d91704SNamjae Jeon int err; 19898d91704SNamjae Jeon 19998d91704SNamjae Jeon mutex_lock(&sbi->s_lock); 2007dee6f57SChristophe Vu-Brugier if (ei->start_clu == 0) { 20198d91704SNamjae Jeon /* 20298d91704SNamjae Jeon * Empty start_clu != ~0 (not allocated) 20398d91704SNamjae Jeon */ 20498d91704SNamjae Jeon exfat_fs_error(sb, "tried to truncate zeroed cluster."); 20598d91704SNamjae Jeon goto write_size; 20698d91704SNamjae Jeon } 20798d91704SNamjae Jeon 208*f7cde967SYuezhang Mo err = __exfat_truncate(inode); 20998d91704SNamjae Jeon if (err) 21098d91704SNamjae Jeon goto write_size; 21198d91704SNamjae Jeon 21292fba084SChristophe Vu-Brugier inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 21392fba084SChristophe Vu-Brugier inode->i_blkbits; 21498d91704SNamjae Jeon write_size: 21598d91704SNamjae Jeon aligned_size = i_size_read(inode); 21698d91704SNamjae Jeon if (aligned_size & (blocksize - 1)) { 21798d91704SNamjae Jeon aligned_size |= (blocksize - 1); 21898d91704SNamjae Jeon aligned_size++; 21998d91704SNamjae Jeon } 22098d91704SNamjae Jeon 2217dee6f57SChristophe Vu-Brugier if (ei->i_size_ondisk > i_size_read(inode)) 2227dee6f57SChristophe Vu-Brugier ei->i_size_ondisk = aligned_size; 22398d91704SNamjae Jeon 2247dee6f57SChristophe Vu-Brugier if (ei->i_size_aligned > i_size_read(inode)) 2257dee6f57SChristophe Vu-Brugier ei->i_size_aligned = aligned_size; 22698d91704SNamjae Jeon mutex_unlock(&sbi->s_lock); 22798d91704SNamjae Jeon } 22898d91704SNamjae Jeon 229549c7297SChristian Brauner int exfat_getattr(struct user_namespace *mnt_uerns, const struct path *path, 230549c7297SChristian Brauner struct kstat *stat, unsigned int request_mask, 231549c7297SChristian Brauner unsigned int query_flags) 23298d91704SNamjae Jeon { 23398d91704SNamjae Jeon struct inode *inode = d_backing_inode(path->dentry); 23498d91704SNamjae Jeon struct exfat_inode_info *ei = EXFAT_I(inode); 23598d91704SNamjae Jeon 2360d56a451SChristian Brauner generic_fillattr(&init_user_ns, inode, stat); 23781df1ad4SEric Sandeen exfat_truncate_atime(&stat->atime); 23898d91704SNamjae Jeon stat->result_mask |= STATX_BTIME; 23998d91704SNamjae Jeon stat->btime.tv_sec = ei->i_crtime.tv_sec; 24098d91704SNamjae Jeon stat->btime.tv_nsec = ei->i_crtime.tv_nsec; 24198d91704SNamjae Jeon stat->blksize = EXFAT_SB(inode->i_sb)->cluster_size; 24298d91704SNamjae Jeon return 0; 24398d91704SNamjae Jeon } 24498d91704SNamjae Jeon 245549c7297SChristian Brauner int exfat_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, 246549c7297SChristian Brauner struct iattr *attr) 24798d91704SNamjae Jeon { 24898d91704SNamjae Jeon struct exfat_sb_info *sbi = EXFAT_SB(dentry->d_sb); 24998d91704SNamjae Jeon struct inode *inode = dentry->d_inode; 25098d91704SNamjae Jeon unsigned int ia_valid; 25198d91704SNamjae Jeon int error; 25298d91704SNamjae Jeon 25398d91704SNamjae Jeon if ((attr->ia_valid & ATTR_SIZE) && 25498d91704SNamjae Jeon attr->ia_size > i_size_read(inode)) { 25598d91704SNamjae Jeon error = exfat_cont_expand(inode, attr->ia_size); 25698d91704SNamjae Jeon if (error || attr->ia_valid == ATTR_SIZE) 25798d91704SNamjae Jeon return error; 25898d91704SNamjae Jeon attr->ia_valid &= ~ATTR_SIZE; 25998d91704SNamjae Jeon } 26098d91704SNamjae Jeon 26198d91704SNamjae Jeon /* Check for setting the inode time. */ 26298d91704SNamjae Jeon ia_valid = attr->ia_valid; 26398d91704SNamjae Jeon if ((ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) && 26498d91704SNamjae Jeon exfat_allow_set_time(sbi, inode)) { 26598d91704SNamjae Jeon attr->ia_valid &= ~(ATTR_MTIME_SET | ATTR_ATIME_SET | 26698d91704SNamjae Jeon ATTR_TIMES_SET); 26798d91704SNamjae Jeon } 26898d91704SNamjae Jeon 2692f221d6fSChristian Brauner error = setattr_prepare(&init_user_ns, dentry, attr); 27098d91704SNamjae Jeon attr->ia_valid = ia_valid; 27198d91704SNamjae Jeon if (error) 27298d91704SNamjae Jeon goto out; 27398d91704SNamjae Jeon 27498d91704SNamjae Jeon if (((attr->ia_valid & ATTR_UID) && 27598d91704SNamjae Jeon !uid_eq(attr->ia_uid, sbi->options.fs_uid)) || 27698d91704SNamjae Jeon ((attr->ia_valid & ATTR_GID) && 27798d91704SNamjae Jeon !gid_eq(attr->ia_gid, sbi->options.fs_gid)) || 27898d91704SNamjae Jeon ((attr->ia_valid & ATTR_MODE) && 27998d91704SNamjae Jeon (attr->ia_mode & ~(S_IFREG | S_IFLNK | S_IFDIR | 0777)))) { 28098d91704SNamjae Jeon error = -EPERM; 28198d91704SNamjae Jeon goto out; 28298d91704SNamjae Jeon } 28398d91704SNamjae Jeon 28498d91704SNamjae Jeon /* 28598d91704SNamjae Jeon * We don't return -EPERM here. Yes, strange, but this is too 28698d91704SNamjae Jeon * old behavior. 28798d91704SNamjae Jeon */ 28898d91704SNamjae Jeon if (attr->ia_valid & ATTR_MODE) { 28998d91704SNamjae Jeon if (exfat_sanitize_mode(sbi, inode, &attr->ia_mode) < 0) 29098d91704SNamjae Jeon attr->ia_valid &= ~ATTR_MODE; 29198d91704SNamjae Jeon } 29298d91704SNamjae Jeon 2934493895bSYuezhang Mo if (attr->ia_valid & ATTR_SIZE) 2944493895bSYuezhang Mo inode->i_mtime = inode->i_ctime = current_time(inode); 2954493895bSYuezhang Mo 2964493895bSYuezhang Mo setattr_copy(&init_user_ns, inode, attr); 2974493895bSYuezhang Mo exfat_truncate_atime(&inode->i_atime); 2984493895bSYuezhang Mo 29998d91704SNamjae Jeon if (attr->ia_valid & ATTR_SIZE) { 30098d91704SNamjae Jeon error = exfat_block_truncate_page(inode, attr->ia_size); 30198d91704SNamjae Jeon if (error) 30298d91704SNamjae Jeon goto out; 30398d91704SNamjae Jeon 30498d91704SNamjae Jeon down_write(&EXFAT_I(inode)->truncate_lock); 30598d91704SNamjae Jeon truncate_setsize(inode, attr->ia_size); 3064493895bSYuezhang Mo 3074493895bSYuezhang Mo /* 3084493895bSYuezhang Mo * __exfat_write_inode() is called from exfat_truncate(), inode 3094493895bSYuezhang Mo * is already written by it, so mark_inode_dirty() is unneeded. 3104493895bSYuezhang Mo */ 311e981917bSYuezhang Mo exfat_truncate(inode); 31298d91704SNamjae Jeon up_write(&EXFAT_I(inode)->truncate_lock); 3134493895bSYuezhang Mo } else 31498d91704SNamjae Jeon mark_inode_dirty(inode); 31598d91704SNamjae Jeon 31698d91704SNamjae Jeon out: 31798d91704SNamjae Jeon return error; 31898d91704SNamjae Jeon } 31998d91704SNamjae Jeon 320654762dfSHyeongseok Kim static int exfat_ioctl_fitrim(struct inode *inode, unsigned long arg) 321654762dfSHyeongseok Kim { 322654762dfSHyeongseok Kim struct fstrim_range range; 323654762dfSHyeongseok Kim int ret = 0; 324654762dfSHyeongseok Kim 325654762dfSHyeongseok Kim if (!capable(CAP_SYS_ADMIN)) 326654762dfSHyeongseok Kim return -EPERM; 327654762dfSHyeongseok Kim 32870200574SChristoph Hellwig if (!bdev_max_discard_sectors(inode->i_sb->s_bdev)) 329654762dfSHyeongseok Kim return -EOPNOTSUPP; 330654762dfSHyeongseok Kim 331654762dfSHyeongseok Kim if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range))) 332654762dfSHyeongseok Kim return -EFAULT; 333654762dfSHyeongseok Kim 334654762dfSHyeongseok Kim range.minlen = max_t(unsigned int, range.minlen, 3357b47ef52SChristoph Hellwig bdev_discard_granularity(inode->i_sb->s_bdev)); 336654762dfSHyeongseok Kim 337654762dfSHyeongseok Kim ret = exfat_trim_fs(inode, &range); 338654762dfSHyeongseok Kim if (ret < 0) 339654762dfSHyeongseok Kim return ret; 340654762dfSHyeongseok Kim 341654762dfSHyeongseok Kim if (copy_to_user((struct fstrim_range __user *)arg, &range, sizeof(range))) 342654762dfSHyeongseok Kim return -EFAULT; 343654762dfSHyeongseok Kim 344654762dfSHyeongseok Kim return 0; 345654762dfSHyeongseok Kim } 346654762dfSHyeongseok Kim 347654762dfSHyeongseok Kim long exfat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 348654762dfSHyeongseok Kim { 349654762dfSHyeongseok Kim struct inode *inode = file_inode(filp); 350654762dfSHyeongseok Kim 351654762dfSHyeongseok Kim switch (cmd) { 352654762dfSHyeongseok Kim case FITRIM: 353654762dfSHyeongseok Kim return exfat_ioctl_fitrim(inode, arg); 354654762dfSHyeongseok Kim default: 355654762dfSHyeongseok Kim return -ENOTTY; 356654762dfSHyeongseok Kim } 357654762dfSHyeongseok Kim } 358654762dfSHyeongseok Kim 359654762dfSHyeongseok Kim #ifdef CONFIG_COMPAT 360654762dfSHyeongseok Kim long exfat_compat_ioctl(struct file *filp, unsigned int cmd, 361654762dfSHyeongseok Kim unsigned long arg) 362654762dfSHyeongseok Kim { 363654762dfSHyeongseok Kim return exfat_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); 364654762dfSHyeongseok Kim } 365654762dfSHyeongseok Kim #endif 366654762dfSHyeongseok Kim 3675267456eSSungjong Seo int exfat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync) 3685267456eSSungjong Seo { 3695267456eSSungjong Seo struct inode *inode = filp->f_mapping->host; 3705267456eSSungjong Seo int err; 3715267456eSSungjong Seo 3725267456eSSungjong Seo err = __generic_file_fsync(filp, start, end, datasync); 3735267456eSSungjong Seo if (err) 3745267456eSSungjong Seo return err; 3755267456eSSungjong Seo 3765267456eSSungjong Seo err = sync_blockdev(inode->i_sb->s_bdev); 3775267456eSSungjong Seo if (err) 3785267456eSSungjong Seo return err; 3795267456eSSungjong Seo 380c6bf3f0eSChristoph Hellwig return blkdev_issue_flush(inode->i_sb->s_bdev); 3815267456eSSungjong Seo } 3825267456eSSungjong Seo 38398d91704SNamjae Jeon const struct file_operations exfat_file_operations = { 38498d91704SNamjae Jeon .llseek = generic_file_llseek, 38598d91704SNamjae Jeon .read_iter = generic_file_read_iter, 38698d91704SNamjae Jeon .write_iter = generic_file_write_iter, 387654762dfSHyeongseok Kim .unlocked_ioctl = exfat_ioctl, 388654762dfSHyeongseok Kim #ifdef CONFIG_COMPAT 389654762dfSHyeongseok Kim .compat_ioctl = exfat_compat_ioctl, 390654762dfSHyeongseok Kim #endif 39198d91704SNamjae Jeon .mmap = generic_file_mmap, 3925267456eSSungjong Seo .fsync = exfat_file_fsync, 39398d91704SNamjae Jeon .splice_read = generic_file_splice_read, 39403577948SEric Sandeen .splice_write = iter_file_splice_write, 39598d91704SNamjae Jeon }; 39698d91704SNamjae Jeon 39798d91704SNamjae Jeon const struct inode_operations exfat_file_inode_operations = { 39898d91704SNamjae Jeon .setattr = exfat_setattr, 39998d91704SNamjae Jeon .getattr = exfat_getattr, 40098d91704SNamjae Jeon }; 401