Patches attached:

#1: allan noah's suggestion (small warning, 5 seconds, that's it)
#2: untested "it compiles" patch for warning file (with Seth's 2 week
    recommendation on time-span)

[ Saturday, March 18, 2000 ] m. allan noah wrote:
> think about it! rm by default does not -i!

true, although most systems (just going by RH's volume) have alias rm="rm
-i" for root (as well as a couple of other possibly-destructive commands)

> i feel that mingo/gadi et al have done a fine job, and these utils need to
> take the same approach as other system level programs- no convoluted messages
> asking for non-disclosure, just the normal warning, and the five second pause.
> raid 0.90 is almost grown up. it should act that way.

raid 0.90 maturity is orthogonal to the issue of whether we want to warn
people on a potentially destructive command.  The motivation "It really
sucks to LOSE DATA!" applys equally well to Bug-Free (tm) kernel code
as to stuff in development (ie, you're willing to destroy what's on disk).

In any case, since the patches are small and easy to get almost any
warning behavior desired (or none at all), it'll boil down to distro
preference anyway.

James
--- raidtools-0.90/mkraid.c.orig        Sun Mar 19 03:31:48 2000
+++ raidtools-0.90/mkraid.c     Sun Mar 19 03:33:46 2000
@@ -68,7 +68,6 @@
     int version = 0, help = 0, debug = 0;
     char * configFile = RAID_CONFIG;
     int force_flag = 0;
-    int old_force_flag = 0;
     int upgrade_flag = 0;
     int no_resync_flag = 0;
     int all_flag = 0;
@@ -79,8 +78,7 @@
     enum mkraidFunc func;
     struct poptOption optionsTable[] = {
        { "configfile", 'c', POPT_ARG_STRING, &configFile, 0 },
-       { "force", 'f', 0, &old_force_flag, 0 },
-       { "really-force", 'R', 0, &force_flag, 0 },
+       { "force", 'f', 0, &force_flag, 0 },
        { "upgrade", 'u', 0, &upgrade_flag, 0 },
        { "dangerous-no-resync", 'r', 0, &no_resync_flag, 0 },
        { "help", 'h', 0, &help, 0 },
@@ -116,12 +114,8 @@
        }
     } else if (!strcmp (namestart, "raid0run")) {
         func = raid0run;
-       if (old_force_flag) {
-               fprintf (stderr, "--force not possible for raid0run!\n");
-               return (EXIT_FAILURE);
-       }
        if (force_flag) {
-               fprintf (stderr, "--really-force not possible for raid0run!\n");
+               fprintf (stderr, "--force not possible for raid0run!\n");
                return (EXIT_FAILURE);
        }
        if (upgrade_flag) {
@@ -167,23 +161,6 @@
 
     if (getMdVersion(&ver)) {
        fprintf(stderr, "cannot determine md version: %s\n", strerror(errno));
-       return EXIT_FAILURE;
-    }
-
-    if (old_force_flag && (func == mkraid)) {
-       fprintf(stderr, 
-
-"--force and the new RAID 0.90 hot-add/hot-remove functionality should be\n"
-" used with extreme care! If /etc/raidtab is not in sync with the real array\n"
-" configuration, then a --force will DESTROY ALL YOUR DATA. It's especially\n"
-" dangerous to use -f if the array is in degraded mode. \n\n"
-" PLEASE dont mention the --really-force flag in any email, documentation or\n"
-" HOWTO, just suggest the --force flag instead. Thus everybody will read\n"
-" this warning at least once :) It really sucks to LOSE DATA. If you are\n"
-" confident that everything will go ok then you can use the --really-force\n"
-" flag. Also, if you are unsure what this is all about, dont hesitate to\n"
-" ask questions on [EMAIL PROTECTED]\n");
-
        return EXIT_FAILURE;
     }
 
--- raidtools-0.90/mkraid.c.orig        Sun Mar 19 03:31:48 2000
+++ raidtools-0.90/mkraid.c     Sun Mar 19 03:55:19 2000
@@ -68,7 +68,6 @@
     int version = 0, help = 0, debug = 0;
     char * configFile = RAID_CONFIG;
     int force_flag = 0;
-    int old_force_flag = 0;
     int upgrade_flag = 0;
     int no_resync_flag = 0;
     int all_flag = 0;
@@ -79,8 +78,7 @@
     enum mkraidFunc func;
     struct poptOption optionsTable[] = {
        { "configfile", 'c', POPT_ARG_STRING, &configFile, 0 },
-       { "force", 'f', 0, &old_force_flag, 0 },
-       { "really-force", 'R', 0, &force_flag, 0 },
+       { "force", 'f', 0, &force_flag, 0 },
        { "upgrade", 'u', 0, &upgrade_flag, 0 },
        { "dangerous-no-resync", 'r', 0, &no_resync_flag, 0 },
        { "help", 'h', 0, &help, 0 },
@@ -116,12 +114,8 @@
        }
     } else if (!strcmp (namestart, "raid0run")) {
         func = raid0run;
-       if (old_force_flag) {
-               fprintf (stderr, "--force not possible for raid0run!\n");
-               return (EXIT_FAILURE);
-       }
        if (force_flag) {
-               fprintf (stderr, "--really-force not possible for raid0run!\n");
+               fprintf (stderr, "--force not possible for raid0run!\n");
                return (EXIT_FAILURE);
        }
        if (upgrade_flag) {
@@ -170,8 +164,17 @@
        return EXIT_FAILURE;
     }
 
-    if (old_force_flag && (func == mkraid)) {
-       fprintf(stderr, 
+    if (force_flag && (func == mkraid)) {
+#define DAYS 86400 /* seconds in a day */
+       char warning_file[256];
+       struct stat stat_buf;
+       char *home=getenv("HOME");
+       strcpy(warning_file,home);
+       strcat(warning_file,"/.md_warning_read");
+       if( (stat(warning_file,&stat_buf) != 0) &&  /* file doesn't exist */
+            (time(NULL) - stat_buf.st_ctime > (14*DAYS) ) ) { /* > 2 weeks */
+           int warn_fd;
+           fprintf(stderr, 
 
 "--force and the new RAID 0.90 hot-add/hot-remove functionality should be\n"
 " used with extreme care! If /etc/raidtab is not in sync with the real array\n"
@@ -184,7 +187,10 @@
 " flag. Also, if you are unsure what this is all about, dont hesitate to\n"
 " ask questions on [EMAIL PROTECTED]\n");
 
-       return EXIT_FAILURE;
+           warn_fd=creat(warning_file,0666);
+           close(warn_fd);
+           return EXIT_FAILURE;
+       }
     }
 
     if (debug) {

Reply via email to