Don't check if a drive is a tape drive unless needed

Garrett Kajmowicz gkajmowi at tbaytel.net
Sat Feb 25 05:09:13 UTC 2006


By default fdisk on performs a sanity check on the type of drive in the event 
that it's autoselected through fdisk -l
In short, let's do compile-time determination instead of run-time 
determination of which code needs to be executed.

Also, is the code for checking if something is a CDROM or a tape drive still 
important?  The comments in the code note that running fdisk -l on an audio 
cdrom drive could cause it to crash.  Event if it still occurs, do we really 
care?

-     Garrett

--- busybox/util-linux/fdisk.c  2006-02-25 00:04:21.000000000 -0500
+++ busybox-new/util-linux/fdisk.c      2006-02-25 00:03:50.000000000 -0500
@@ -5445,14 +5445,11 @@


 static void
-try(const char *device, int user_specified)
+try(const char *device)
 {
        int gb;

        disk_device = device;
-       if (!user_specified)
-               if (is_ide_cdrom_or_tape(device))
-                       return;
        if ((fd = open(disk_device, type_open)) >= 0) {
                gb = get_boot(try_only);
                if (gb > 0) {   /* I/O error */
@@ -5508,7 +5505,9 @@
                if (isdigit(s[-1]))
                        continue;
                sprintf(devname, "/dev/%s", ptname);
-               try(devname, 0);
+               if (!is_ide_cdrom_or_tape(devname)){
+                       try(devname);
+               }
        }
 #ifdef CONFIG_FEATURE_CLEAN_UP
        fclose(procpt);
@@ -5612,7 +5611,7 @@
                if (argc > optind) {
                        int k;
                        for (k = optind; k < argc; k++)
-                               try(argv[k], 1);
+                               try(argv[k]);
                } else {
                        /* we no longer have default device names */
                        /* but, we can use /proc/partitions instead */



More information about the busybox mailing list