mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
create_floppy_devices: fix logic for more than one floppy device
This commit is contained in:
parent
2bb4dd9766
commit
be580fa5d8
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user