diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 19:35:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 19:35:21 -0500 |
commit | 9d85929fefd040ca84a5e04ee704d043efcc3c2e (patch) | |
tree | 34cdd0f79f656962fe0aada6b603620a6afc294a | |
parent | 6db823cf4b44f235b5e1da8ec1fe3c3cd63647fe (diff) | |
parent | eeb5b4ae81f4a750355fa0c15f4fea22fdf83be1 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/hirofumi/fatfs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/hirofumi/fatfs-2.6:
fat: Fix stat->f_namelen
fat: Fix vfat_lookup()
-rw-r--r-- | fs/fat/inode.c | 2 | ||||
-rw-r--r-- | fs/fat/namei_vfat.c | 27 | ||||
-rw-r--r-- | include/linux/msdos_fs.h | 3 |
3 files changed, 22 insertions, 10 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index fbeecdc194dc..0ce143bd7d56 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -558,7 +558,7 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
558 | buf->f_bavail = sbi->free_clusters; | 558 | buf->f_bavail = sbi->free_clusters; |
559 | buf->f_fsid.val[0] = (u32)id; | 559 | buf->f_fsid.val[0] = (u32)id; |
560 | buf->f_fsid.val[1] = (u32)(id >> 32); | 560 | buf->f_fsid.val[1] = (u32)(id >> 32); |
561 | buf->f_namelen = sbi->options.isvfat ? 260 : 12; | 561 | buf->f_namelen = sbi->options.isvfat ? FAT_LFN_LEN : 12; |
562 | 562 | ||
563 | return 0; | 563 | return 0; |
564 | } | 564 | } |
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index f565f24019b5..c1ef50154868 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
@@ -502,14 +502,14 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, | |||
502 | *outlen = utf8s_to_utf16s(name, len, (wchar_t *)outname); | 502 | *outlen = utf8s_to_utf16s(name, len, (wchar_t *)outname); |
503 | if (*outlen < 0) | 503 | if (*outlen < 0) |
504 | return *outlen; | 504 | return *outlen; |
505 | else if (*outlen > 255) | 505 | else if (*outlen > FAT_LFN_LEN) |
506 | return -ENAMETOOLONG; | 506 | return -ENAMETOOLONG; |
507 | 507 | ||
508 | op = &outname[*outlen * sizeof(wchar_t)]; | 508 | op = &outname[*outlen * sizeof(wchar_t)]; |
509 | } else { | 509 | } else { |
510 | if (nls) { | 510 | if (nls) { |
511 | for (i = 0, ip = name, op = outname, *outlen = 0; | 511 | for (i = 0, ip = name, op = outname, *outlen = 0; |
512 | i < len && *outlen <= 255; | 512 | i < len && *outlen <= FAT_LFN_LEN; |
513 | *outlen += 1) | 513 | *outlen += 1) |
514 | { | 514 | { |
515 | if (escape && (*ip == ':')) { | 515 | if (escape && (*ip == ':')) { |
@@ -549,7 +549,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, | |||
549 | return -ENAMETOOLONG; | 549 | return -ENAMETOOLONG; |
550 | } else { | 550 | } else { |
551 | for (i = 0, ip = name, op = outname, *outlen = 0; | 551 | for (i = 0, ip = name, op = outname, *outlen = 0; |
552 | i < len && *outlen <= 255; | 552 | i < len && *outlen <= FAT_LFN_LEN; |
553 | i++, *outlen += 1) | 553 | i++, *outlen += 1) |
554 | { | 554 | { |
555 | *op++ = *ip++; | 555 | *op++ = *ip++; |
@@ -701,6 +701,15 @@ static int vfat_find(struct inode *dir, struct qstr *qname, | |||
701 | return fat_search_long(dir, qname->name, len, sinfo); | 701 | return fat_search_long(dir, qname->name, len, sinfo); |
702 | } | 702 | } |
703 | 703 | ||
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 | |||
704 | static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | 713 | static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, |
705 | struct nameidata *nd) | 714 | struct nameidata *nd) |
706 | { | 715 | { |
@@ -729,11 +738,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
729 | } | 738 | } |
730 | 739 | ||
731 | alias = d_find_alias(inode); | 740 | alias = d_find_alias(inode); |
732 | if (alias && !(alias->d_flags & DCACHE_DISCONNECTED)) { | 741 | if (alias && !vfat_d_anon_disconn(alias)) { |
733 | /* | 742 | /* |
734 | * This inode has non DCACHE_DISCONNECTED dentry. This | 743 | * This inode has non anonymous-DCACHE_DISCONNECTED |
735 | * means, the user did ->lookup() by an another name | 744 | * dentry. This means, the user did ->lookup() by an |
736 | * (longname vs 8.3 alias of it) in past. | 745 | * another name (longname vs 8.3 alias of it) in past. |
737 | * | 746 | * |
738 | * Switch to new one for reason of locality if possible. | 747 | * Switch to new one for reason of locality if possible. |
739 | */ | 748 | */ |
@@ -743,7 +752,9 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
743 | iput(inode); | 752 | iput(inode); |
744 | unlock_super(sb); | 753 | unlock_super(sb); |
745 | return alias; | 754 | return alias; |
746 | } | 755 | } else |
756 | dput(alias); | ||
757 | |||
747 | out: | 758 | out: |
748 | unlock_super(sb); | 759 | unlock_super(sb); |
749 | dentry->d_op = sb->s_root->d_op; | 760 | dentry->d_op = sb->s_root->d_op; |
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h index ce38f1caa5e1..34066e65fdeb 100644 --- a/include/linux/msdos_fs.h +++ b/include/linux/msdos_fs.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */ | 15 | #define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */ |
16 | #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry)) | 16 | #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry)) |
17 | #define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */ | 17 | #define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */ |
18 | #define MSDOS_LONGNAME 256 /* maximum name length */ | ||
18 | #define CF_LE_W(v) le16_to_cpu(v) | 19 | #define CF_LE_W(v) le16_to_cpu(v) |
19 | #define CF_LE_L(v) le32_to_cpu(v) | 20 | #define CF_LE_L(v) le32_to_cpu(v) |
20 | #define CT_LE_W(v) cpu_to_le16(v) | 21 | #define CT_LE_W(v) cpu_to_le16(v) |
@@ -47,8 +48,8 @@ | |||
47 | #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ | 48 | #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ |
48 | #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) | 49 | #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) |
49 | 50 | ||
51 | #define FAT_LFN_LEN 255 /* maximum long name length */ | ||
50 | #define MSDOS_NAME 11 /* maximum name length */ | 52 | #define MSDOS_NAME 11 /* maximum name length */ |
51 | #define MSDOS_LONGNAME 256 /* maximum name length */ | ||
52 | #define MSDOS_SLOTS 21 /* max # of slots for short and long names */ | 53 | #define MSDOS_SLOTS 21 /* max # of slots for short and long names */ |
53 | #define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */ | 54 | #define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */ |
54 | #define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ | 55 | #define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ |