summaryrefslogtreecommitdiff
path: root/extras/floppy
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-12-17 03:41:30 +0100
committerKay Sievers <kay.sievers@vrfy.org>2007-12-17 03:41:30 +0100
commitbe580fa5d83ef4b73b71f29ebd76b1f26eb12e9c (patch)
tree1cb0cea1dfbbff1727d82785d73583c5776a30a9 /extras/floppy
parent2bb4dd9766479348a2829ceb8ef583a788bfd840 (diff)
create_floppy_devices: fix logic for more than one floppy device
Diffstat (limited to 'extras/floppy')
-rw-r--r--extras/floppy/create_floppy_devices.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/extras/floppy/create_floppy_devices.c b/extras/floppy/create_floppy_devices.c
index b9fa4ef41d..d79a782abf 100644
--- a/extras/floppy/create_floppy_devices.c
+++ b/extras/floppy/create_floppy_devices.c
@@ -69,6 +69,7 @@ void log_message(int priority, const char *format, ...)
int main(int argc, char **argv)
{
char *dev;
+ char *devname;
char node[64];
int type = 0, i, fdnum, c;
int major = 2, minor;
@@ -123,12 +124,17 @@ int main(int argc, char **argv)
}
dev = argv[optind];
- if (dev[strlen(dev) - 3] != 'f' || dev[strlen(dev) -2 ] != 'd') {
+ devname = strrchr(dev, '/');
+ if (devname != NULL)
+ devname = &devname[1];
+ else
+ devname = dev;
+ if (strncmp(devname, "fd", 2) != 0) {
fprintf(stderr,"Device '%s' is not a floppy device\n", dev);
return 1;
}
- fdnum = strtol(dev + 2, NULL, 10);
+ fdnum = strtol(&devname[2], NULL, 10);
if (fdnum < 0 || fdnum > 7) {
fprintf(stderr,"Floppy device number %d out of range (0-7)\n", fdnum);
return 1;