Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160AbdLZQRB (ORCPT ); Tue, 26 Dec 2017 11:17:01 -0500 Received: from mail.parknet.co.jp ([210.171.160.6]:34746 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750822AbdLZQQ7 (ORCPT ); Tue, 26 Dec 2017 11:16:59 -0500 From: OGAWA Hirofumi To: ChenGuanqiao Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/2] fs: fat: add ioctl method in fat filesystem driver References: <20171225112020.2267-1-chen.chenchacha@foxmail.com> <20171225112020.2267-3-chen.chenchacha@foxmail.com> Date: Wed, 27 Dec 2017 01:16:57 +0900 In-Reply-To: <20171225112020.2267-3-chen.chenchacha@foxmail.com> (ChenGuanqiao's message of "Mon, 25 Dec 2017 19:20:20 +0800") Message-ID: <87po71wjk6.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1021 Lines: 43 ChenGuanqiao writes: > +static int fat_check_volume_label(const char *label) > +{ > + int i; > + > + for (i=0; i<11; ++i) { > + if (islower(label[i])) > + return -EINVAL; > + } > + return 0; > +} What happen if '\0' is included, or invalid chars as FAT filename? > +static int fat_ioctl_get_volume_label(struct inode *inode, > + u8 __user *vol_label) > +{ > + int err = 0; > + struct buffer_head *bh; > + struct msdos_dir_entry *de; > + struct super_block *sb = inode->i_sb; > + struct msdos_sb_info *sbi = MSDOS_SB(sb); > + > + if (sbi->fat_bits == 32) > + bh = sb_bread(sb, sbi->data_start); > + else > + bh = sb_bread(sb, sbi->dir_start); > + > + if (bh == NULL) { > + fat_msg(sb, KERN_ERR, "unable to read root directory"); > + err = -EIO; > + goto out; > + } > + > + de = (struct msdos_dir_entry *)bh->b_data; The volume label is not fixed place in root dir. You have to find ATTR_VOLUME, but not ATTR_EXT. Thanks. -- OGAWA Hirofumi