Received: by 10.223.176.5 with SMTP id f5csp2846237wra; Mon, 29 Jan 2018 05:05:03 -0800 (PST) X-Google-Smtp-Source: AH8x225wGAjaHTqkZ22oZvqrPLMHKSPVu5VOWkf+gEw4D3NcMxNW7mkmg37f0iWzducrtS/1t6wL X-Received: by 2002:a17:902:3225:: with SMTP id y34-v6mr21626164plb.399.1517231102961; Mon, 29 Jan 2018 05:05:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517231102; cv=none; d=google.com; s=arc-20160816; b=nzd/dZn15C3R8YiZBWdr9w12lTZUUxifVylQJI5hCwx6sr7O/gJtrqsR5e0T7YIoIV Zmip0Swe8cD/K5v2GjuEshyll2nF5hh3iQMyoq/caeRaGcLQxpRTHIvRs92cwG3WP77S GKcMqJDJuWDMvdZVYI5o4QyJaBg/6F8SKDEp8PzLUKS2Z9zbRc93HfvhyrdjFOYjezCM j0hILLnrbAPPlS9akMbziFmpjeZ+WzSb5oeNE61wBtZE5pMkT15oC8WCvd2+1sukfjJT Ij1e9kA55tO667o7tiHbBmOUIEcwC3+YH0v8cfeDIVc9cqyeqCZIBb0bzWFMmtBVFoC+ LPdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=JZL6rpwTgeUdYnqHtNywKk5lwIFPA6NLQCosRuQceBk=; b=q4tH7Uq0Z80VavbrTiuNVqdh5OrIWY3VomXCIp62I4b72YVtBD4c1jyMczPEv2BcTC tf+XhJ38wwBKH8JXHo7Rd1gPUh4inPVlnBorMYFN9Yz0B5pvuw7YfiyPGPrs8r7WgLsd 6l/p8G7wlMTcS+XB2Cinm0kDJh/HHQaWqvN9b/hQGhzfPiNGDRtV3s2kt7po/z21ztdb Gnts6LqD8lfylX8H4aQLE2NMsukcD0NLDiS24dGD/VuhWAcdlKfU9BjlMaflyBtHI+75 zRoyflXWVLK41vmrHVGjrYHskuWhfhE8Oed0qrVMWQNv22cYYZbmGDpEbUSxIlgLf/mI UlXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si4433999ple.338.2018.01.29.05.04.48; Mon, 29 Jan 2018 05:05:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751997AbeA2NCs (ORCPT + 99 others); Mon, 29 Jan 2018 08:02:48 -0500 Received: from mail.parknet.co.jp ([210.171.160.6]:44661 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751822AbeA2NCr (ORCPT ); Mon, 29 Jan 2018 08:02:47 -0500 Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTP id C90371E0018; Mon, 29 Jan 2018 22:02:45 +0900 (JST) Received: from devron.myhome.or.jp (root@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.15.2/8.15.2/Debian-10) with ESMTPS id w0TD2ixK022331 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Jan 2018 22:02:45 +0900 Received: from devron.myhome.or.jp (hirofumi@localhost [127.0.0.1]) by devron.myhome.or.jp (8.15.2/8.15.2/Debian-10) with ESMTPS id w0TD2i2g014228 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Jan 2018 22:02:44 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.15.2/8.15.2/Submit) id w0TD2h57014227; Mon, 29 Jan 2018 22:02:43 +0900 From: OGAWA Hirofumi To: ChenGuanqiao Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] fs: fat: add ioctl method in fat filesystem driver References: <20180117104355.889-1-chen.chenchacha@foxmail.com> <20180117104355.889-4-chen.chenchacha@foxmail.com> Date: Mon, 29 Jan 2018 22:02:43 +0900 In-Reply-To: <20180117104355.889-4-chen.chenchacha@foxmail.com> (ChenGuanqiao's message of "Wed, 17 Jan 2018 18:43:55 +0800") Message-ID: <87r2q8n7gs.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ChenGuanqiao writes: > +static int fat_check_d_characters(char *label, unsigned long len) > +{ > + int i; > + > + for (i = 0; i < len; ++i) { > + switch (label[i]) { > + case 'a' ... 'z': > + label[i] = __toupper(label[i]); > + case 'A' ... 'Z': > + case '0' ... '9': > + case '_': > + case 0x20: > + continue; > + default: > + return -EINVAL; > + } Same question with previous though, what windows do if label = "a b c"? (this is including space other than end of name or extension.) > + } > + > + return 0; > +} > +static int fat_ioctl_set_volume_label(struct file *file, > + u8 __user *vol_label) > +{ > + int err = 0; > + u8 label[MSDOS_NAME]; > + struct timespec ts; > + struct buffer_head *boot_bh; > + struct buffer_head *vol_bh; > + struct msdos_dir_entry *de; > + struct fat_boot_sector *b; > + struct inode *inode = file_inode(file); > + struct super_block *sb = inode->i_sb; > + struct msdos_sb_info *sbi = MSDOS_SB(sb); > + [...] > + err = mnt_want_write_file(file); > + if (err) > + goto out; > + > + down_write(&sb->s_umount); Looks like inode_lock() for rootdir is gone. It is necessary to traverse+modify. > + /* Updates root directory's vol_label */ > + err = fat_get_volume_label_entry(inode, &vol_bh, &de); > + ts = current_time(inode); > + if (err) { > + /* Create volume label entry */ > + err = fat_add_volume_label_entry(inode, label, &ts); > + if (err) > + goto out_vol_brelse; > + } else { > + /* Write to root directory */ > + memcpy(de->name, label, sizeof(de->name)); > + inode->i_ctime = inode->i_mtime = inode->i_atime = ts; > + > + mark_buffer_dirty(vol_bh); > + } > + > + /* Update sector's vol_label */ > + boot_bh = sb_bread(sb, 0); > + if (boot_bh == NULL) { > + fat_msg(sb, KERN_ERR, > + "unable to read boot sector to write volume label"); > + err = -EIO; > + goto out_boot_brelse; > + } > + > + b = (struct fat_boot_sector *)boot_bh->b_data; > + if (sbi->fat_bits == 32) > + memcpy(b->fat32.vol_label, label, sizeof(label)); > + else > + memcpy(b->fat16.vol_label, label, sizeof(label)); > + > + mark_buffer_dirty(boot_bh); > + > + /* Synchronize the data together */ > + err = sync_dirty_buffer(boot_bh); > + if (err) > + goto out_boot_brelse; -- OGAWA Hirofumi