[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <00d201d5a00c$e6273ac0$b275b040$@samsung.com>
Date: Thu, 21 Nov 2019 10:42:13 +0900
From: "Namjae Jeon" <namjae.jeon@...sung.com>
To: "'Nikolay Borisov'" <nborisov@...e.com>
Cc: <gregkh@...uxfoundation.org>, <valdis.kletnieks@...edu>,
<hch@....de>, <linkinjeon@...il.com>, <Markus.Elfring@....de>,
<sj1557.seo@...sung.com>, <linux-kernel@...r.kernel.org>,
<linux-fsdevel@...r.kernel.org>
Subject: RE: [PATCH v2 05/13] exfat: add file operations
> > +static int exfat_allow_set_time(struct exfat_sb_info *sbi, struct inode
> *inode)
> > +{
> > + mode_t allow_utime = sbi->options.allow_utime;
> > +
> > + if (!uid_eq(current_fsuid(), inode->i_uid)) {
> > + if (in_group_p(inode->i_gid))
> > + allow_utime >>= 3;
> > + if (allow_utime & MAY_WRITE)
> > + return 1;
> > + }
> > +
> > + /* use a default check */
> > + return 0;
>
> this function can be made to return bool.
Okay.
>
> > +}
> > +
>
> <snip>
>
> > +/* resize the file length */
> > +int __exfat_truncate(struct inode *inode, loff_t new_size)
> > +{
> > + unsigned int num_clusters_new, num_clusters_phys;
> > + unsigned int last_clu = FREE_CLUSTER;
> > + struct exfat_chain clu;
> > + struct exfat_timestamp tm;
> > + struct exfat_dentry *ep, *ep2;
> > + struct super_block *sb = inode->i_sb;
> > + struct exfat_sb_info *sbi = EXFAT_SB(sb);
> > + struct exfat_inode_info *ei = EXFAT_I(inode);
> > + struct exfat_entry_set_cache *es = NULL;
> > + int evict = (ei->dir.dir == DIR_DELETED) ? 1 : 0;
> > +
> > + /* check if the given file ID is opened */
> > + if (ei->type != TYPE_FILE && ei->type != TYPE_DIR)
> > + return -EPERM;
> > +
> > + exfat_set_vol_flags(sb, VOL_DIRTY);
> > +
> > + num_clusters_new = EXFAT_B_TO_CLU_ROUND_UP(i_size_read(inode), sbi);
> > + num_clusters_phys =
> > + EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk, sbi);
> > +
> > + exfat_chain_set(&clu, ei->start_clu, num_clusters_phys, ei->flags);
> > +
> > + if (new_size > 0) {
> > + /*
> > + * Truncate FAT chain num_clusters after the first cluster
> > + * num_clusters = min(new, phys);
> > + */
> > + unsigned int num_clusters =
> > + min(num_clusters_new, num_clusters_phys);
> > +
> > + /*
> > + * Follow FAT chain
> > + * (defensive coding - works fine even with corrupted FAT table
> > + */
> > + if (clu.flags == 0x03) {
>
> That 0x03 is magic constant, better define actual flags and check
> clu.flag == (FLAG1|FLAG2)
Okay, Will fix it on v4.
Thanks for your review!
Powered by blists - more mailing lists