From nobody Thu Apr 2 15:37:26 2026 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C0D733342E for ; Tue, 10 Feb 2026 22:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770762199; cv=none; b=X9rHU9uaQh/NPxa/GkQd3YLQSQOY3FFrlSHpXgjTRw/9gdq6oXCxX1IUpgSV5cS2N3tAxfiohjuM8nFYeTd8ZsUOwsoMoStFJSJZowAXAUHnqyywZYbN0vvurPlnOjHA3CAYTzVShI0wQqVhIZfA/AlP9sq/3wSq0s2V2g8XDQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770762199; c=relaxed/simple; bh=zFxFA1GCM8gPEXiEVpKpj+s09Uajmn5lAzVTqkSN9Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BZR8bMWGRWqqhD2lRLO6keZUaNzKl9dIwpMdtctwOH7aJvrcTe1pGKUB/GTc78biHiN3AQy4heq/cAymrwCy6/O/eYTzWZFCSPtTfTPIaxG4HTciEyKP+sFzYhEz58rLa1r5g7UE0ABio3caPOQqAXMbE5LQ0ZrvOiWvFlUcgu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=zetier.com; spf=pass smtp.mailfrom=zetier.com; dkim=pass (2048-bit key) header.d=zetier.com header.i=@zetier.com header.b=PAlZHgJQ; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=zetier.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zetier.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zetier.com header.i=@zetier.com header.b="PAlZHgJQ" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-5014b7de222so61161911cf.0 for ; Tue, 10 Feb 2026 14:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zetier.com; s=gm; t=1770762197; x=1771366997; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jdhijZyb/fF9pYUtdTXLnhISRtfqTlYJBcsQJEZtO1s=; b=PAlZHgJQkUJ28cEsifn1a3PURrAzE6uvHTBhfkDzgR3CTJJvdvF3BgmGE38zlH39Tc 789r8GrWl6YAJj7tBkw1k4GNSKtAVcYtAwcUv+c/c0pxjxmorx4zUQyeXdCEumIhZqRj 8cSYrC5euFPwYuk+vPmJ4MRLt0yWlL1AJus+7yvPVQb414y8J5JMjkX9pS1Th32nM6Uo HMrLpNh3ruZCMEE32IMZG8K799JHSI8giDZF+c/HAdtWRF/fVhA2LLv5LpyBcsBCb3Oc 9yS3VpHz3wqobPTOCIk9H3dqbGWuLfa7/E0X6p/X1bXzIF9cHrIfqgVOB+ECSfL+iNZ5 kA6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770762197; x=1771366997; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jdhijZyb/fF9pYUtdTXLnhISRtfqTlYJBcsQJEZtO1s=; b=MktkSLsxzu/qIgXkj0axlI5drkESHwOJcnXBSWJisbPiPJ2oZefj1+DBKcFKWuRw2T cUeHYffu1Ag/3/TVCrmi7FBr81fTn9J9fuQ5M/Eh6yC+leb04JpO20meFvISIIsdWBbC BJcFtLAROYapxLcJT/VZDcwaVC3feniZebtttGfLkWNk/tTchJwWFgKAMRiUnHKssxLz +JI/Llic6xD8KYmdzBJU1ne+D436OGdYnH6BKjajxzEntqGeiYVJNqleacXzo9VGMtf2 RvJjFgnpmUa8MP5vD/c3bYusIX4fY3L569S0N68oJgP6uqemFPucO4Hd6bndfeIOTYHZ wEKw== X-Forwarded-Encrypted: i=1; AJvYcCW+cKRrjPOZlV4oLTckMpoYFdBLiB9Pjys19GTid1L41LLHAJXM33rJnsJH6n7qwNLb7Fqyl+1JF3Rmrl4=@vger.kernel.org X-Gm-Message-State: AOJu0YzPv9y6CAHGRn1OdjV2PChbtkjVx0TSj0oZxnpWGPUfMJG4N2aT xFpDJ7eZqP5jiOlTwArB7m3to3/rTeeT4meSaQYlb/tHgCPJR7tCI3R3L7Fy0PztvoU= X-Gm-Gg: AZuq6aI0ndSPNxSLqsmoy4ejCGS00E2AO+wXylDKoH3gZpqUHD4kP8osjgsLZ2VphW+ 9ymsGJOK89hpy7J3RMVz+5IRVAhdjAmB6DW2Z+ifX2ZvFrtm0yMOq8sZqU/6vtBOfEykN3vrkmV BBbQFYWcv4CESnQ4Emx64efnbaMWHCKklY9jfYh5bW04ITep/OlcrMXyCbgtkmdPPo9r6Sl20sl K3PgokiSUjbMmbIat5wxM3wVChquDA/qgZGHrnp5tBFTd5nASnQCqY9OBZ67gbVRtU4bGZLH5OA SuQIe1u8ypVphuVHBsgVl8UZZmXuwJQVnB6ht5dPxKi3lh/U7HP5Y9ADMXjy6SFcVo9PqhgGk+H GL5DcnnF4+cXGIaxgJaJKQotUw/PVLZAaxmsYXOmOQ5PRB8fi1QtjVtD4FHhoYWZv7SzCPXmhQO djNTI9iffKhwsLfSzqlq8Pp4yXXXnZ2cCYANipPiZEc9r/KuyyK5sQtI0NAYTqooX/l10bxjmc1 oFPeXAbpmTqP7k= X-Received: by 2002:ac8:7f4d:0:b0:502:a28c:f195 with SMTP id d75a77b69052e-50673cf1be3mr46438771cf.13.1770762197149; Tue, 10 Feb 2026 14:23:17 -0800 (PST) Received: from warpstation.incus (243.69.21.34.bc.googleusercontent.com. [34.21.69.243]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50682edead7sm646801cf.7.2026.02.10.14.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 14:23:16 -0800 (PST) From: Ethan Ferguson To: hirofumi@mail.parknet.co.jp Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ethan Ferguson Subject: [PATCH 1/2] fat: Add FS_IOC_GETFSLABEL ioctl Date: Tue, 10 Feb 2026 17:23:09 -0500 Message-ID: <20260210222310.357755-2-ethan.ferguson@zetier.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260210222310.357755-1-ethan.ferguson@zetier.com> References: <20260210222310.357755-1-ethan.ferguson@zetier.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for reading the volume label of a FAT filesystem via the FS_IOC_GETFSLABEL ioctl. Signed-off-by: Ethan Ferguson --- fs/fat/fat.h | 1 + fs/fat/file.c | 9 +++++++++ fs/fat/inode.c | 11 +++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/fs/fat/fat.h b/fs/fat/fat.h index d3e426de5f01..db9c854ddef8 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h @@ -89,6 +89,7 @@ struct msdos_sb_info { int dir_per_block; /* dir entries per block */ int dir_per_block_bits; /* log2(dir_per_block) */ unsigned int vol_id; /*volume ID*/ + char vol_label[MSDOS_NAME]; /* volume label */ =20 int fatent_shift; const struct fatent_operations *fatent_ops; diff --git a/fs/fat/file.c b/fs/fat/file.c index 4fc49a614fb8..c55a99009a9c 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -153,6 +153,13 @@ static int fat_ioctl_fitrim(struct inode *inode, unsig= ned long arg) return 0; } =20 +static int fat_ioctl_get_volume_label(struct inode *inode, char __user *ar= g) +{ + struct msdos_sb_info *sbi =3D MSDOS_SB(inode->i_sb); + + return copy_to_user(arg, sbi->vol_label, MSDOS_NAME); +} + long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long = arg) { struct inode *inode =3D file_inode(filp); @@ -165,6 +172,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 FS_IOC_GETFSLABEL: + return fat_ioctl_get_volume_label(inode, (char __user *) arg); case FITRIM: return fat_ioctl_fitrim(inode, arg); default: diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 0b6009cd1844..f6bd3f079e74 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -53,12 +53,14 @@ struct fat_bios_param_block { =20 u8 fat16_state; u32 fat16_vol_id; + u8 fat16_vol_label[MSDOS_NAME]; =20 u32 fat32_length; u32 fat32_root_cluster; u16 fat32_info_sector; u8 fat32_state; u32 fat32_vol_id; + u8 fat32_vol_label[MSDOS_NAME]; }; =20 static int fat_default_codepage =3D CONFIG_FAT_DEFAULT_CODEPAGE; @@ -1406,12 +1408,14 @@ static int fat_read_bpb(struct super_block *sb, str= uct fat_boot_sector *b, =20 bpb->fat16_state =3D b->fat16.state; bpb->fat16_vol_id =3D get_unaligned_le32(b->fat16.vol_id); + memcpy(bpb->fat16_vol_label, b->fat16.vol_label, MSDOS_NAME); =20 bpb->fat32_length =3D le32_to_cpu(b->fat32.length); bpb->fat32_root_cluster =3D le32_to_cpu(b->fat32.root_cluster); bpb->fat32_info_sector =3D le16_to_cpu(b->fat32.info_sector); bpb->fat32_state =3D b->fat32.state; bpb->fat32_vol_id =3D get_unaligned_le32(b->fat32.vol_id); + memcpy(bpb->fat32_vol_label, b->fat32.vol_label, MSDOS_NAME); =20 /* Validate this looks like a FAT filesystem BPB */ if (!bpb->fat_reserved) { @@ -1708,10 +1712,13 @@ int fat_fill_super(struct super_block *sb, struct f= s_context *fc, } =20 /* interpret volume ID as a little endian 32 bit integer */ - if (is_fat32(sbi)) + if (is_fat32(sbi)) { sbi->vol_id =3D bpb.fat32_vol_id; - else /* fat 16 or 12 */ + memcpy(sbi->vol_label, bpb.fat32_vol_label, MSDOS_NAME); + } else { /* fat 16 or 12 */ sbi->vol_id =3D bpb.fat16_vol_id; + memcpy(sbi->vol_label, bpb.fat16_vol_label, MSDOS_NAME); + } =20 __le32 vol_id_le =3D cpu_to_le32(sbi->vol_id); super_set_uuid(sb, (void *) &vol_id_le, sizeof(vol_id_le)); --=20 2.53.0 From nobody Thu Apr 2 15:37:26 2026 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FA6F306483 for ; Tue, 10 Feb 2026 22:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770762200; cv=none; b=b00ZJ0gWNNFHNOIGsgAf02sUNyIxl7vusN+GUf0OdRiiYrZdjluwb4eliJllHWbeKJMSEJT1TVGFB0XGQfYhMG+V/AYwqFSW5HbcO2y/jKbE83edmVC881uLaspuKyig3TMjyaEhr3Mil4wVLxKo0Mfccok/xB6UeSvny4GWKcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770762200; c=relaxed/simple; bh=m6kuT4ru0pzsc9PoL8u98ZqQt+Y4v5WSn+QSSceV3h8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iDJUT10+LxZkxnZOYKqHWJy9BfphmafF+RfiwGbCQGfMU8QqxBzLfThA1pwY2jBQzvE2X977yoRFTvDlZk/vxZN6M8XH2CHn/CFSmAptNcuVxJO8DCPHN3iV1XsdAuw/zJlfM6xRlowzvPcHqQPxUE5YfSrS2rfuo0rEZ0v8zsE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=zetier.com; spf=pass smtp.mailfrom=zetier.com; dkim=pass (2048-bit key) header.d=zetier.com header.i=@zetier.com header.b=WjwwxfHZ; arc=none smtp.client-ip=209.85.160.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=zetier.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zetier.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zetier.com header.i=@zetier.com header.b="WjwwxfHZ" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-5033a2c4b81so52607721cf.0 for ; Tue, 10 Feb 2026 14:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zetier.com; s=gm; t=1770762199; x=1771366999; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=img53VqC7R04RkA7EExplxfa/I0yMn636xW9pad0/C0=; b=WjwwxfHZpFnfNu/jlAZ3RYNqn8ZFNr979TJtEc85iK5g+V2cIa4WwcIqxm7sGQUZoF YxMEUH92dY9VZiA8rkAo8XXFycFalAqrXgjwU6TVdA2Ww1A1PaFhhacmsCmAgCX3lhz4 Jhm8n10XfisEURrIMNRaphB1LvnsO8LOdk/Bkcz2wr5KoE1s/wCFqhGj9JQp9B7qpzZq S9rTO8p+BmTnr1Y9ZdFdTpI3GI+wTFLk034sC+1hXnQTbGsUidNbVmalpPFEkbExU+3Z 6YNecv2Mam0m0R95wwY0E0ZmyScrabG7Pi8DGsyGFmJ73gKW5Pfhm/CbIth7wUVEXP6b O0Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770762199; x=1771366999; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=img53VqC7R04RkA7EExplxfa/I0yMn636xW9pad0/C0=; b=vlKeuv5tg9arnDSQj+rheID3YBk5VfqqaiMwz6p7aYtg40OSR3C2uCnCJx6AkUdmw7 2PWtMnfCNA49Y9Td5igxGqwGLsaIx/zhFFBY3CsHDTNquPYhoRePWAAc018eqx0qhY9L 2KMNZGVOZ43Kh2MRNoXl6m+OrcwFZLMl7JhZDrqjXS13Jvl1plWEpi3kmwF0+TD6ws4c iFT/uep1gsSPW7+NuS4sUt4vFZi7v8n/8EiRXsIEZK9PJpW8cZ3LPbliKzkON6UT0zh0 +nmrC0Kygp0UrtSxBgA4ggh4YGwKAYjidoHVwrYPywN+9VjooA01eh7UDHDf2foi6hg1 3fYg== X-Forwarded-Encrypted: i=1; AJvYcCV9uR+BrgtxBgIpOBaU5Qqx51QL1IETNp1CQ74Eur//Ei5wq/xhLXfuEPSqHDx74s+/5yjwZgoIOiNmEME=@vger.kernel.org X-Gm-Message-State: AOJu0YyjSxo5wh1lWmAXyAMsBC56APB9lIfx1Y8v+dehEHzP5LVQf42Z 33HBRY7g/UDxSgAkOnEWzNg0Z4wlAmDHE+QSONdH9csStix4gYsudqCiQVV2WMX68Ns= X-Gm-Gg: AZuq6aK5oYdhH6W9+kvPPNRjSuLVBYZswI6vH0D9VOomukWGItf4X9Q1bxN0k1j5ecU rbT+ttiiqmfF1FJhf9NRearY5aWW/oPxbp9Ytl7jwXADdmz9kn662JgeVJK+eI+xBJEjsAsaWJl EO+K+oBCFAb7cyQndXJ/YLkTVO9Nf/vD/xfmBecqBzeTkGw0G5Z041A1vJVDvJEGMPQEqw+qrmY 72H033Jy6Ca/HcwLCjHw6m3MpQrO645Qb5socbLNH95aiZ/uAIS7W2V4l2dIXcVxkVW2KmAyL/2 KjgV9781RTt+2URnp6kuksZunBUhPFWQlkgZ7geNqmohKDiovRRjdqSMcpz8/QenJwXcCDnBF25 GPfyV9EIhEWtzn9DqWQwj4nDMPW0FZpyW8p1CSBB3L/K09zcl+H8qfpcL99YrAzGBSAL5mjDSkv M15/91Y1k03bDW785dEC6jVy5IKcjjSSX1vf8WZKVMqe8/I9Vv4JBmSTJBxLvEabM70c3jNTvwX y7V X-Received: by 2002:ac8:5ad6:0:b0:502:6312:8d6 with SMTP id d75a77b69052e-5068102b723mr12240941cf.12.1770762198654; Tue, 10 Feb 2026 14:23:18 -0800 (PST) Received: from warpstation.incus (243.69.21.34.bc.googleusercontent.com. [34.21.69.243]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50682edead7sm646801cf.7.2026.02.10.14.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 14:23:18 -0800 (PST) From: Ethan Ferguson To: hirofumi@mail.parknet.co.jp Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ethan Ferguson Subject: [PATCH 2/2] fat: Add FS_IOC_SETFSLABEL ioctl Date: Tue, 10 Feb 2026 17:23:10 -0500 Message-ID: <20260210222310.357755-3-ethan.ferguson@zetier.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260210222310.357755-1-ethan.ferguson@zetier.com> References: <20260210222310.357755-1-ethan.ferguson@zetier.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for writing to the volume label of a FAT filesystem via the FS_IOC_SETFSLABEL ioctl. Signed-off-by: Ethan Ferguson --- fs/fat/dir.c | 22 ++++++++++++++++++++++ fs/fat/fat.h | 1 + fs/fat/file.c | 19 +++++++++++++++++++ fs/fat/inode.c | 15 +++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 92b091783966..13e87f4c6bf3 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -1423,3 +1423,25 @@ int fat_add_entries(struct inode *dir, void *slots, = int nr_slots, return err; } EXPORT_SYMBOL_GPL(fat_add_entries); + +int fat_rename_volume_label_dentry(struct super_block *sb, char *vol_label) +{ + struct inode *root_inode =3D sb->s_root->d_inode; + struct buffer_head *bh; + struct msdos_dir_entry *de; + loff_t cpos =3D 0; + + while (1) { + if (fat_get_entry(root_inode, &cpos, &bh, &de) =3D=3D -1) + return -ENOENT; + + if (de->attr =3D=3D ATTR_VOLUME) { + memcpy(de->name, vol_label, MSDOS_NAME); + mark_inode_dirty(root_inode); + return 0; + } + + brelse(bh); + } +} +EXPORT_SYMBOL_GPL(fat_rename_volume_label_dentry); diff --git a/fs/fat/fat.h b/fs/fat/fat.h index db9c854ddef8..5f1536c21adf 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h @@ -341,6 +341,7 @@ extern int fat_alloc_new_dir(struct inode *dir, struct = timespec64 *ts); extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots, struct fat_slot_info *sinfo); extern int fat_remove_entries(struct inode *dir, struct fat_slot_info *sin= fo); +extern int fat_rename_volume_label_dentry(struct super_block *sb, char *vo= l_label); =20 /* fat/fatent.c */ struct fat_entry { diff --git a/fs/fat/file.c b/fs/fat/file.c index c55a99009a9c..2475a8f58596 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -160,6 +160,23 @@ static int fat_ioctl_get_volume_label(struct inode *in= ode, char __user *arg) return copy_to_user(arg, sbi->vol_label, MSDOS_NAME); } =20 +static int fat_ioctl_set_volume_label(struct inode *inode, char __user *ar= g) +{ + struct msdos_sb_info *sbi =3D MSDOS_SB(inode->i_sb); + char new_vol_label[MSDOS_NAME]; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (copy_from_user(new_vol_label, arg, MSDOS_NAME)) + return -EFAULT; + + fat_rename_volume_label_dentry(inode->i_sb, new_vol_label); + + memcpy(sbi->vol_label, new_vol_label, MSDOS_NAME); + return 0; +} + long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long = arg) { struct inode *inode =3D file_inode(filp); @@ -174,6 +191,8 @@ long fat_generic_ioctl(struct file *filp, unsigned int = cmd, unsigned long arg) return fat_ioctl_get_volume_id(inode, user_attr); case FS_IOC_GETFSLABEL: return fat_ioctl_get_volume_label(inode, (char __user *) arg); + case FS_IOC_SETFSLABEL: + return fat_ioctl_set_volume_label(inode, (char __user *) arg); case FITRIM: return fat_ioctl_fitrim(inode, arg); default: diff --git a/fs/fat/inode.c b/fs/fat/inode.c index f6bd3f079e74..b40abb2b0010 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -736,6 +736,21 @@ static void delayed_free(struct rcu_head *p) static void fat_put_super(struct super_block *sb) { struct msdos_sb_info *sbi =3D MSDOS_SB(sb); + struct buffer_head *bh =3D NULL; + struct fat_boot_sector *bs; + + bh =3D sb_bread(sb, 0); + if (bh =3D=3D NULL) + fat_msg(sb, KERN_ERR, "unable to read boot sector"); + else if (!sb_rdonly(sb)) { + bs =3D (struct fat_boot_sector *)bh->b_data; + if (is_fat32(sbi)) + memcpy(bs->fat32.vol_label, sbi->vol_label, MSDOS_NAME); + else + memcpy(bs->fat16.vol_label, sbi->vol_label, MSDOS_NAME); + mark_buffer_dirty(bh); + } + brelse(bh); =20 fat_set_state(sb, 0, 0); =20 --=20 2.53.0