On Friday 05 October 2018 01:21:01 chenchacha wrote:
> Signed-off-by: chenchacha <chen.chencha...@foxmail.com>
> ---
>  fs/fat/dir.c | 13 +++++++++++++
>  fs/fat/fat.h |  2 ++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/fs/fat/dir.c b/fs/fat/dir.c
> index 7f5f3699fc6c..4fdcc1200f2b 100644
> --- a/fs/fat/dir.c
> +++ b/fs/fat/dir.c
> @@ -881,6 +881,19 @@ static int fat_get_short_entry(struct inode *dir, loff_t 
> *pos,
>       return -ENOENT;
>  }
>  
> +int fat_get_root_entry(struct inode *dir, struct buffer_head **bh,
> +                    struct msdos_dir_entry **de)

fat_get_root_volume_entry would be better name. It does not return root
entry, but volume label entry.

> +{
> +     loff_t offset = 0;
> +
> +     *de = NULL;
> +     while (fat_get_entry(dir, &offset, bh, de) >= 0) {
> +             if (!IS_FREE((*de)->name) && (*de)->attr & ATTR_VOLUME)

You should check that cluster number is zero. As e.g. first entry with
ATTR_VOLUME can be also LFN entry and not real volume label. So you
should properly check mask and filter out also LFN entries which have
ATTR_VOLUME flag set too.

> +                     return 0;
> +     }
> +     return -ENOENT;
> +}
> +
>  /*
>   * The ".." entry can not provide the "struct fat_slot_info" information
>   * for inode, nor a usable i_pos. So, this function provides some information
> diff --git a/fs/fat/fat.h b/fs/fat/fat.h
> index be012de96f65..4195cb1e891a 100644
> --- a/fs/fat/fat.h
> +++ b/fs/fat/fat.h
> @@ -302,6 +302,8 @@ extern int fat_scan(struct inode *dir, const unsigned 
> char *name,
>                   struct fat_slot_info *sinfo);
>  extern int fat_scan_logstart(struct inode *dir, int i_logstart,
>                            struct fat_slot_info *sinfo);
> +extern int fat_get_root_entry(struct inode *dir, struct buffer_head **bh,
> +                           struct msdos_dir_entry **de);
>  extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh,
>                               struct msdos_dir_entry **de);
>  extern int fat_alloc_new_dir(struct inode *dir, struct timespec64 *ts);
> -- 
> 2.19.0
> 

-- 
Pali Rohár
pali.ro...@gmail.com

Attachment: signature.asc
Description: PGP signature

Reply via email to