From mboxrd@z Thu Jan 1 00:00:00 1970 From: Namjae Jeon Subject: Re: [PATCH v5 5/8] fat: restructure export_operations Date: Tue, 4 Dec 2012 15:23:27 +0900 Message-ID: References: <1353504277-5947-1-git-send-email-linkinjeon@gmail.com> <87hao35uqz.fsf@devron.myhome.or.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Namjae Jeon , Ravishankar N , Amit Sahrawat To: OGAWA Hirofumi Return-path: In-Reply-To: <87hao35uqz.fsf@devron.myhome.or.jp> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 2012/12/3, OGAWA Hirofumi : > Namjae Jeon writes: > >> + if (MSDOS_SB(inode->i_sb)->options.nfs =3D=3D FAT_NFS_NOSTALE_RO) = { >> + /* Use i_pos for ino. This is used as fileid of nfs. */ >> + stat->ino =3D fat_i_pos_read(MSDOS_SB(inode->i_sb), inode); > > BTW, what number is used for root dir? If it is 0 (0 is special ino i= n > glibc), we have to use MSDOS_ROOT_INO instead. we have used default root ino number which is MSDOS_ROOT_INO. > >> +#define FAT_FID_SIZE_WITHOUT_PARENT (offsetof(struct fat_fid, \ >> + parent_i_pos_hi)/4) > > (offset parent_i_pos_hi) / 4 =3D=3D 2. Wrong. Yes, this needs correction. Since, at all the places the condition was for =E2=80=98fh_len < 2=E2=80=99 so this error condition was never = caught. > >> +#define FAT_FID_SIZE_WITH_PARENT (sizeof(struct fat_fid)/4) > > 4 should be sizeof(u32). Or simplely use immediate value. Okay. > >> +static int >> +fat_encode_fh_nostale(struct inode *inode, __u32 *fh, int *lenp, >> + struct inode *parent) >> +{ >> + int len =3D *lenp; >> + struct msdos_sb_info *sbi =3D MSDOS_SB(inode->i_sb); >> + struct fat_fid *fid =3D (struct fat_fid *) fh; >> + loff_t i_pos; >> + int type =3D FILEID_FAT_WITHOUT_PARENT; >> + >> + if (parent && (len < FAT_FID_SIZE_WITH_PARENT)) { >> + *lenp =3D FAT_FID_SIZE_WITH_PARENT; >> + return 255; > > 255 is now FILEID_INVALID, I think. Yes, right. > >> + } else if (len < FAT_FID_SIZE_WITHOUT_PARENT) { >> + *lenp =3D FAT_FID_SIZE_WITHOUT_PARENT; >> + return 255; >> + } >> + >> + i_pos =3D fat_i_pos_read(sbi, inode); >> + *lenp =3D FAT_FID_SIZE_WITHOUT_PARENT; >> + fid->i_gen =3D inode->i_generation; >> + fid->i_pos_low =3D i_pos & 0xFFFFFFFF; >> + fid->i_pos_hi =3D (i_pos >> 32) & 0xFFFF; >> + if (parent) { >> + i_pos =3D fat_i_pos_read(sbi, parent); >> + fid->parent_i_pos_hi =3D (i_pos >> 32) & 0xFFFF; >> + fid->parent_i_pos_low =3D i_pos & 0xFFFFFFFF; >> + fid->parent_i_gen =3D parent->i_generation; >> + type =3D FILEID_FAT_WITH_PARENT; >> + *lenp =3D FAT_FID_SIZE_WITH_PARENT; >> + } >> + >> + return type; >> +} >> + >> /** >> * Map a NFS file handle to a corresponding dentry. >> * The dentry may or may not be connected to the filesystem root. >> */ >> -struct dentry *fat_fh_to_dentry(struct super_block *sb, struct fid = *fid, >> +static struct dentry *fat_fh_to_dentry(struct super_block *sb, stru= ct fid >> *fid, >> int fh_len, int fh_type) >> { >> return generic_fh_to_dentry(sb, fid, fh_len, fh_type, >> fat_nfs_get_inode); >> } >> >> +static struct dentry *fat_fh_to_dentry_nostale(struct super_block *= sb, >> + struct fid *fh, int fh_len, >> + int fh_type) >> +{ >> + struct inode *inode =3D NULL; >> + struct fat_fid *fid =3D (struct fat_fid *)fh; >> + loff_t i_pos; >> + >> + switch (fh_type) { >> + case FILEID_FAT_WITHOUT_PARENT: >> + if (fh_len < FAT_FID_SIZE_WITHOUT_PARENT) >> + return NULL; >> + case FILEID_FAT_WITH_PARENT: >> + if ((fh_len < FAT_FID_SIZE_WITH_PARENT) && >> + (fh_type =3D=3D FILEID_FAT_WITH_PARENT)) >> + return NULL; > > Do we have to care (FILEID_FAT_WITH_PARENT and fh_len < 5) here? > > if (fh_len < 2) > return NULL; > > switch (fh_type) { > case FILEID_INO32_GEN: > case FILEID_INO32_GEN_PARENT: > inode =3D get_inode(sb, fid->i32.ino, fid->i32.gen); > break; > } > > return d_obtain_alias(inode); > > generic_fh_to_dentry() is above. I wonder why we have to care > fat_fid->parent* here. Let me think, if =E2=80=98subtree=E2=80=99 checking is enabled then we = should check the length condition over here also? Please share if there are any other comments also. Thanks. > -- > OGAWA Hirofumi >