Commit 9d85929f authored by Linus Torvalds's avatar Linus Torvalds
parents 6db823cf eeb5b4ae
...@@ -558,7 +558,7 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -558,7 +558,7 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_bavail = sbi->free_clusters; buf->f_bavail = sbi->free_clusters;
buf->f_fsid.val[0] = (u32)id; buf->f_fsid.val[0] = (u32)id;
buf->f_fsid.val[1] = (u32)(id >> 32); buf->f_fsid.val[1] = (u32)(id >> 32);
buf->f_namelen = sbi->options.isvfat ? 260 : 12; buf->f_namelen = sbi->options.isvfat ? FAT_LFN_LEN : 12;
return 0; return 0;
} }
......
...@@ -502,14 +502,14 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -502,14 +502,14 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
*outlen = utf8s_to_utf16s(name, len, (wchar_t *)outname); *outlen = utf8s_to_utf16s(name, len, (wchar_t *)outname);
if (*outlen < 0) if (*outlen < 0)
return *outlen; return *outlen;
else if (*outlen > 255) else if (*outlen > FAT_LFN_LEN)
return -ENAMETOOLONG; return -ENAMETOOLONG;
op = &outname[*outlen * sizeof(wchar_t)]; op = &outname[*outlen * sizeof(wchar_t)];
} else { } else {
if (nls) { if (nls) {
for (i = 0, ip = name, op = outname, *outlen = 0; for (i = 0, ip = name, op = outname, *outlen = 0;
i < len && *outlen <= 255; i < len && *outlen <= FAT_LFN_LEN;
*outlen += 1) *outlen += 1)
{ {
if (escape && (*ip == ':')) { if (escape && (*ip == ':')) {
...@@ -549,7 +549,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -549,7 +549,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
return -ENAMETOOLONG; return -ENAMETOOLONG;
} else { } else {
for (i = 0, ip = name, op = outname, *outlen = 0; for (i = 0, ip = name, op = outname, *outlen = 0;
i < len && *outlen <= 255; i < len && *outlen <= FAT_LFN_LEN;
i++, *outlen += 1) i++, *outlen += 1)
{ {
*op++ = *ip++; *op++ = *ip++;
...@@ -701,6 +701,15 @@ static int vfat_find(struct inode *dir, struct qstr *qname, ...@@ -701,6 +701,15 @@ static int vfat_find(struct inode *dir, struct qstr *qname,
return fat_search_long(dir, qname->name, len, sinfo); return fat_search_long(dir, qname->name, len, sinfo);
} }
/*
* (nfsd's) anonymous disconnected dentry?
* NOTE: !IS_ROOT() is not anonymous (I.e. d_splice_alias() did the job).
*/
static int vfat_d_anon_disconn(struct dentry *dentry)
{
return IS_ROOT(dentry) && (dentry->d_flags & DCACHE_DISCONNECTED);
}
static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd) struct nameidata *nd)
{ {
...@@ -729,11 +738,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -729,11 +738,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
} }
alias = d_find_alias(inode); alias = d_find_alias(inode);
if (alias && !(alias->d_flags & DCACHE_DISCONNECTED)) { if (alias && !vfat_d_anon_disconn(alias)) {
/* /*
* This inode has non DCACHE_DISCONNECTED dentry. This * This inode has non anonymous-DCACHE_DISCONNECTED
* means, the user did ->lookup() by an another name * dentry. This means, the user did ->lookup() by an
* (longname vs 8.3 alias of it) in past. * another name (longname vs 8.3 alias of it) in past.
* *
* Switch to new one for reason of locality if possible. * Switch to new one for reason of locality if possible.
*/ */
...@@ -743,7 +752,9 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -743,7 +752,9 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
iput(inode); iput(inode);
unlock_super(sb); unlock_super(sb);
return alias; return alias;
} } else
dput(alias);
out: out:
unlock_super(sb); unlock_super(sb);
dentry->d_op = sb->s_root->d_op; dentry->d_op = sb->s_root->d_op;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */ #define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */
#define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry)) #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
#define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */ #define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */
#define MSDOS_LONGNAME 256 /* maximum name length */
#define CF_LE_W(v) le16_to_cpu(v) #define CF_LE_W(v) le16_to_cpu(v)
#define CF_LE_L(v) le32_to_cpu(v) #define CF_LE_L(v) le32_to_cpu(v)
#define CT_LE_W(v) cpu_to_le16(v) #define CT_LE_W(v) cpu_to_le16(v)
...@@ -47,8 +48,8 @@ ...@@ -47,8 +48,8 @@
#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
#define FAT_LFN_LEN 255 /* maximum long name length */
#define MSDOS_NAME 11 /* maximum name length */ #define MSDOS_NAME 11 /* maximum name length */
#define MSDOS_LONGNAME 256 /* maximum name length */
#define MSDOS_SLOTS 21 /* max # of slots for short and long names */ #define MSDOS_SLOTS 21 /* max # of slots for short and long names */
#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */ #define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ #define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment