lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  2 Jan 2018 14:42:28 +0800
From:   ChenGuanqiao <chen.chenchacha@...mail.com>
To:     hirofumi@...l.parknet.co.jp
Cc:     linux-kernel@...r.kernel.org,
        ChenGuanqiao <chen.chenchacha@...mail.com>
Subject: [PATCH v6 2/3] fs: fat: Add volume label entry method function

Signed-off-by: ChenGuanqiao <chen.chenchacha@...mail.com>
---
 fs/fat/dir.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 81cecbe6d7cf..63aab656c08e 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -881,6 +881,68 @@ static int fat_get_short_entry(struct inode *dir, loff_t *pos,
	return -ENOENT;
 }

+static int fat_get_volume_label_entry(struct inode *dir, loff_t *pos,
+			       struct buffer_head **bh,
+			       struct msdos_dir_entry **de)
+{
+	while (fat_get_entry(dir, pos, bh, de) >= 0) {
+		if (((*de)->attr & ATTR_VOLUME) && (*de)->attr != ATTR_EXT)
+			return 0;
+	}
+	return -ENOENT;
+}
+
+int fat_scan_volume_label(struct inode *dir, struct buffer_head **bh,
+			  struct msdos_dir_entry **de)
+{
+	loff_t offset = 0;
+
+	if (dir->i_ino != MSDOS_ROOT_INO)
+		return -EINVAL;
+
+	*bh = NULL;
+	*de = NULL;
+	while (fat_get_volume_label_entry(dir, &offset, bh, de) >= 0)
+		return 0;
+
+	return -ENOENT;
+}
+EXPORT_SYMBOL_GPL(fat_scan_volume_label);
+
+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 -EINVAL;
+
+	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;
+
+	dir->i_ctime = dir->i_mtime = *ts;
+
+	return fat_sync_inode(dir);
+}
+EXPORT_SYMBOL_GPL(fat_add_volume_label_entry);
+
 /*
  * The ".." entry can not provide the "struct fat_slot_info" information
  * for inode, nor a usable i_pos. So, this function provides some information
--
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ