All of lore.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: ChenGuanqiao <chen.chenchacha@foxmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/3] fs: fat: Add volume label entry method function
Date: Sun, 14 Jan 2018 21:50:50 +0900	[thread overview]
Message-ID: <87bmhweh91.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20180110102153.12388-3-chen.chenchacha@foxmail.com> (ChenGuanqiao's message of "Wed, 10 Jan 2018 18:21:52 +0800")

ChenGuanqiao <chen.chenchacha@foxmail.com> writes:

> Signed-off-by: ChenGuanqiao <chen.chenchacha@foxmail.com>
> ---
>  fs/fat/dir.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>
> diff --git a/fs/fat/dir.c b/fs/fat/dir.c
> index 8e100c3bf72c..53f36c03760e 100644
> --- a/fs/fat/dir.c
> +++ b/fs/fat/dir.c
> @@ -881,6 +881,59 @@ static int fat_get_short_entry(struct inode *dir, loff_t *pos,
> 	return -ENOENT;
>  }
>
> +int fat_get_volume_label_entry(struct inode *dir, struct buffer_head **bh,
> +			       struct msdos_dir_entry **de)
> +{
> +	loff_t pos = 0;
> +
> +	if (dir->i_ino != MSDOS_ROOT_INO)
> +		return -EFAULT;

Now, dir is always root, so this check doesn't matter.

> +	*bh = NULL;
> +	*de = NULL;
> +	while (fat_get_entry(dir, &pos, bh, de) >= 0) {
> +		if (((*de)->attr & ATTR_VOLUME) && ((*de)->attr != ATTR_EXT) &&
> +		    !IS_FREE((*de)->name))
> +			return 0;
> +	}
> +	return -ENOENT;
> +}
> +EXPORT_SYMBOL_GPL(fat_get_volume_label_entry);
> +
> +int fat_add_volume_label_entry(struct inode *dir, const unsigned char *name,
> +			       struct timespec *ts)
> +{
> +	struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
> +	struct msdos_dir_entry de;
> +	struct fat_slot_info sinfo;
> +	__le16 time, date;
> +	int err;
> +
> +	if (dir->i_ino != MSDOS_ROOT_INO)
> +		return -EFAULT;

Here is too. dir is always root.

> +	memcpy(de.name, name, MSDOS_NAME);
> +	de.attr = ATTR_VOLUME;
> +	de.lcase = 0;
> +	fat_time_unix2fat(sbi, ts, &time, &date, NULL);
> +	de.cdate = de.adate = 0;
> +	de.ctime = 0;
> +	de.ctime_cs = 0;
> +	de.time = time;
> +	de.date = date;
> +	fat_set_start(&de, 0);
> +	de.size = 0;
> +
> +	err = fat_add_entries(dir, &de, 1, &sinfo);
> +	if (err)
> +		return err;
> +
> +	brelse(sinfo.bh);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(fat_add_volume_label_entry);

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2018-01-14 12:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 10:21 [PATCH v7 0/3] fs: fat: add ioctl to modify fat filesystem partion volume label ChenGuanqiao
2018-01-10 10:21 ` [PATCH v7 1/3] fs: fat: Add fat filesystem partition volume label in local structure ChenGuanqiao
2018-01-14 13:18   ` OGAWA Hirofumi
2018-01-10 10:21 ` [PATCH v7 2/3] fs: fat: Add volume label entry method function ChenGuanqiao
2018-01-14 12:50   ` OGAWA Hirofumi [this message]
2018-01-10 10:21 ` [PATCH v7 3/3] fs: fat: add ioctl method in fat filesystem driver ChenGuanqiao
2018-01-14 13:17   ` OGAWA Hirofumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bmhweh91.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=chen.chenchacha@foxmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.