NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/59957 Add minimal support for NAME= syntax
The following reply was made to PR bin/59957; it has been noted by GNATS.
From: ssszcmawo <ssszcmawo%gmail.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/59957 Add minimal support for NAME= syntax
Date: Sun, 1 Mar 2026 16:48:31 +0100
This patch implements minimal support for volume labels
I've tested this change locally on my system and it works
as intended. I hope you won't encounter any issues either.
>From 06cfd7be8f77e78db7bb3c895226020a6564ed62 Mon Sep 17 00:00:00 2001
From: ssszcmawo <belan2470%gmail.com@localhost>
Date: Sun, 1 Mar 2026 16:34:55 +0100
Subject: [PATCH] add support for labels
---
sbin/newfs_msdos/newfs_msdos.c | 42 ++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c
index 9f333b4f9..90bf786ce 100644
--- a/sbin/newfs_msdos/newfs_msdos.c
+++ b/sbin/newfs_msdos/newfs_msdos.c
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: newfs_msdos.c,v 1.45 2017/02/16
22:42:25 christos Exp $");
#include <unistd.h>
#include <paths.h>
#include <errno.h>
+#include <fcntl.h>
#include <util.h>
#include "mkfs_msdos.h"
@@ -93,7 +94,13 @@ main(int argc, char *argv[])
static const char opts[] =
"@:NB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:T:u:";
struct msdos_options o;
char *fname, *dtype;
- char buf[MAXPATHLEN];
+ const char* special;
+ const char* sname;
+ char specname[MAXPATHLEN];
+ char device[MAXPATHLEN];
+ char rawname[MAXPATHLEN];
+ int fd;
+ struct stat sb;
int ch;
memset(&o, 0, sizeof(o));
@@ -183,12 +190,33 @@ main(int argc, char *argv[])
argv += optind;
if (argc < 1 || argc > 2)
usage();
- fname = *argv++;
- if (!strchr(fname, '/') && !o.create_size) {
- snprintf(buf, sizeof(buf), "%sr%s", _PATH_DEV, fname);
- if (!(fname = strdup(buf)))
- err(1, NULL);
- }
+
+ memset(&sb, 0, sizeof(sb));
+
+ special = argv[0];
+
+ sname = getfsspecname(specname, sizeof(specname), special);
+ if (sname == NULL)
+ err(1, "%s: %s",special, specname);
+
+ special = getdiskrawname(rawname, sizeof(rawname), sname);
+ if (special == NULL)
+ special = sname;
+
+ fd = opendisk(special, O_RDWR, device,
+ sizeof(device),0);
+
+ if (fd < 0 || fstat(fd, &sb) == -1)
+ err(1, "%s: open for read", special);
+
+ special = device;
+
+ if (S_ISBLK(sb.st_mode))
+ errx(1, "%s is a block device. use raw device",
+ special);
+
+ fname = strdup(special);
+
dtype = *argv;
return mkfs_msdos(fname, dtype, &o);
}
--
2.47.3
Home |
Main Index |
Thread Index |
Old Index