[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20181004172915.z7zm5jqcb4vtq6py@pali>
Date: Thu, 4 Oct 2018 19:29:15 +0200
From: Pali Rohár <pali.rohar@...il.com>
To: chenchacha <chen.chenchacha@...mail.com>
Cc: hirofumi@...l.parknet.co.jp, linux-kernel@...r.kernel.org,
andy.shevchenko@...il.com
Subject: Re: [PATCH 2/2] Add a new function to get root directory with
ATTR_VOLUME
On Friday 05 October 2018 01:21:01 chenchacha wrote:
> Signed-off-by: chenchacha <chen.chenchacha@...mail.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.rohar@...il.com
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists