@@ -502,14 +502,14 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
502502 * outlen = utf8s_to_utf16s (name , len , (wchar_t * )outname );
503503 if (* outlen < 0 )
504504 return * outlen ;
505- else if (* outlen > 255 )
505+ else if (* outlen > FAT_LFN_LEN )
506506 return - ENAMETOOLONG ;
507507
508508 op = & outname [* outlen * sizeof (wchar_t )];
509509 } else {
510510 if (nls ) {
511511 for (i = 0 , ip = name , op = outname , * outlen = 0 ;
512- i < len && * outlen <= 255 ;
512+ i < len && * outlen <= FAT_LFN_LEN ;
513513 * outlen += 1 )
514514 {
515515 if (escape && (* ip == ':' )) {
@@ -549,7 +549,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
549549 return - ENAMETOOLONG ;
550550 } else {
551551 for (i = 0 , ip = name , op = outname , * outlen = 0 ;
552- i < len && * outlen <= 255 ;
552+ i < len && * outlen <= FAT_LFN_LEN ;
553553 i ++ , * outlen += 1 )
554554 {
555555 * op ++ = * ip ++ ;
@@ -701,6 +701,15 @@ static int vfat_find(struct inode *dir, struct qstr *qname,
701701 return fat_search_long (dir , qname -> name , len , sinfo );
702702}
703703
704+ /*
705+ * (nfsd's) anonymous disconnected dentry?
706+ * NOTE: !IS_ROOT() is not anonymous (I.e. d_splice_alias() did the job).
707+ */
708+ static int vfat_d_anon_disconn (struct dentry * dentry )
709+ {
710+ return IS_ROOT (dentry ) && (dentry -> d_flags & DCACHE_DISCONNECTED );
711+ }
712+
704713static struct dentry * vfat_lookup (struct inode * dir , struct dentry * dentry ,
705714 struct nameidata * nd )
706715{
@@ -729,11 +738,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
729738 }
730739
731740 alias = d_find_alias (inode );
732- if (alias && !(alias -> d_flags & DCACHE_DISCONNECTED )) {
741+ if (alias && !vfat_d_anon_disconn (alias )) {
733742 /*
734- * This inode has non DCACHE_DISCONNECTED dentry. This
735- * means, the user did ->lookup() by an another name
736- * (longname vs 8.3 alias of it) in past.
743+ * This inode has non anonymous- DCACHE_DISCONNECTED
744+ * dentry. This means, the user did ->lookup() by an
745+ * another name (longname vs 8.3 alias of it) in past.
737746 *
738747 * Switch to new one for reason of locality if possible.
739748 */
@@ -743,7 +752,9 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
743752 iput (inode );
744753 unlock_super (sb );
745754 return alias ;
746- }
755+ } else
756+ dput (alias );
757+
747758out :
748759 unlock_super (sb );
749760 dentry -> d_op = sb -> s_root -> d_op ;
0 commit comments