From: "Pali Rohár" <pali.rohar@gmail.com>
To: chenchacha <chen.chenchacha@foxmail.com>
Cc: hirofumi@mail.parknet.co.jp, linux-kernel@vger.kernel.org,
andy.shevchenko@gmail.com
Subject: Re: [PATCH 1/2] Add FAT_IOCTL_GET_VOLUME_LABEL in fat_generic_ioctl()
Date: Thu, 4 Oct 2018 19:33:47 +0200 [thread overview]
Message-ID: <20181004173347.kmymtmiilo7lrxmy@pali> (raw)
In-Reply-To: <20181004172101.15525-2-chen.chenchacha@foxmail.com>
[-- Attachment #1: Type: text/plain, Size: 2603 bytes --]
On Friday 05 October 2018 01:21:00 chenchacha wrote:
> Signed-off-by: chenchacha <chen.chenchacha@foxmail.com>
> ---
> fs/fat/file.c | 22 ++++++++++++++++++++++
> include/uapi/linux/msdos_fs.h | 1 +
> 2 files changed, 23 insertions(+)
>
> diff --git a/fs/fat/file.c b/fs/fat/file.c
> index 4724cc9ad650..56db0b5a8df1 100644
> --- a/fs/fat/file.c
> +++ b/fs/fat/file.c
> @@ -121,10 +121,30 @@ static int fat_ioctl_get_volume_id(struct inode *inode, u32 __user *user_attr)
> return put_user(sbi->vol_id, user_attr);
> }
>
> +static int fat_ioctl_get_volume_label(struct inode *inode, u8 __user *label)
> +{
> + struct super_block *sb = inode->i_sb;
> + struct inode *root_inode = d_inode(sb->s_root);
> + struct buffer_head *bh = NULL;
> + struct msdos_dir_entry *de;
> + int err;
> +
> + inode_lock_shared(root_inode);
> + err = fat_get_root_entry(root_inode, &bh, &de);
> + if (err == 0) {
> + if (copy_to_user(label, de->name, MSDOS_NAME))
You need to convert entry name from 8.3 format to label in correct
encoding specified by codepage mount option. Plus needs to handle
leading 0x03 byte.
> + err = -EFAULT;
> + }
> + inode_unlock_shared(root_inode);
> +
> + return err;
> +}
> +
> long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> {
> struct inode *inode = file_inode(filp);
> u32 __user *user_attr = (u32 __user *)arg;
> + u8 __user *user_vol_label = (u8 __user *)arg;
>
> switch (cmd) {
> case FAT_IOCTL_GET_ATTRIBUTES:
> @@ -133,6 +153,8 @@ long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> return fat_ioctl_set_attributes(filp, user_attr);
> case FAT_IOCTL_GET_VOLUME_ID:
> return fat_ioctl_get_volume_id(inode, user_attr);
> + case FAT_IOCTL_GET_VOLUME_LABEL:
> + return fat_ioctl_get_volume_label(inode, user_vol_label);
> default:
> return -ENOTTY; /* Inappropriate ioctl for device */
> }
> diff --git a/include/uapi/linux/msdos_fs.h b/include/uapi/linux/msdos_fs.h
> index fde753735aba..8ba8e2d7bafe 100644
> --- a/include/uapi/linux/msdos_fs.h
> +++ b/include/uapi/linux/msdos_fs.h
> @@ -109,6 +109,7 @@ struct __fat_dirent {
> #define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
> /*Android kernel has used 0x12, so we use 0x13*/
> #define FAT_IOCTL_GET_VOLUME_ID _IOR('r', 0x13, __u32)
> +#define FAT_IOCTL_GET_VOLUME_LABEL _IOR('r', 0x14, __u8[MSDOS_NAME])
>
> struct fat_boot_sector {
> __u8 ignored[3]; /* Boot strap short or near jump */
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2018-10-04 17:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-04 17:20 [PATCH 0/2] fs: fat: add ioctl method to read voluem label in fat filesystem driver chenchacha
2018-10-04 17:21 ` [PATCH 2/2] Add a new function to get root directory with ATTR_VOLUME chenchacha
2018-10-04 17:29 ` Pali Rohár
2018-10-04 17:26 ` [PATCH 0/2] fs: fat: add ioctl method to read voluem label in fat filesystem driver Pali Rohár
[not found] ` <20181004172101.15525-2-chen.chenchacha@foxmail.com>
2018-10-04 17:33 ` Pali Rohár [this message]
[not found] ` <5bb8734a.1c69fb81.9fdf4.0461SMTPIN_ADDED_BROKEN@mx.google.com>
2018-10-06 8:37 ` [PATCH 1/2] Add FAT_IOCTL_GET_VOLUME_LABEL in fat_generic_ioctl() Pali Rohár
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=20181004173347.kmymtmiilo7lrxmy@pali \
--to=pali.rohar@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=chen.chenchacha@foxmail.com \
--cc=hirofumi@mail.parknet.co.jp \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox