]> andersk Git - moira.git/commitdiff
correct fsgroup re-ordering problem
authormar <mar>
Tue, 12 Jun 1990 16:29:21 +0000 (16:29 +0000)
committermar <mar>
Tue, 12 Jun 1990 16:29:21 +0000 (16:29 +0000)
clients/moira/attach.c

index 268ef4bf53260ff55772350119e7de74199027c7..c56e22a6a9566ebf5b3d4cf995d262c62085beed 100644 (file)
@@ -662,8 +662,8 @@ ChangeFSGroupOrder(argc, argv)
 char **argv;
 int argc;
 {
-    int stat, src, dst;
-    struct qelem *elem = NULL, *top;
+    int stat, src, dst, i;
+    struct qelem *elem = NULL, *top, *tmpelem;
     char buf[BUFSIZ], *bufp, *args[3];
 
     if ((stat = do_mr_query("get_fsgroup_members", 1, argv+1, StoreInfo,
@@ -691,20 +691,34 @@ int argc;
            Put_message("Aborted.");
            return(DM_NORMAL);
        }
-       for (elem = top; src-- > 1 && elem->q_forw; elem = elem->q_forw);
-       if (src > 1) {
+       for (elem = top, i = src; i-- > 1 && elem->q_forw; elem = elem->q_forw);
+       if (i > 0) {
            Put_message("You entered a number that is too high");
            continue;
        }
        break;
     }
-    bufp = Strsave("0");
-    stat = GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp);
-    dst = atoi(bufp);
-    free(bufp);
-    if (src == dst || src == dst + 1) {
-       Put_message("That has no effect on the sorting order!");
-       return(DM_NORMAL);
+    while (1) {
+       bufp = Strsave("0");
+       stat = GetValueFromUser("Enter number of filesystem it should follow (0 to make it first):", &bufp);
+       dst = atoi(bufp);
+       free(bufp);
+       if (src == dst || src == dst + 1) {
+           Put_message("That has no effect on the sorting order!");
+           return(DM_NORMAL);
+       }
+       if (dst < 0) {
+           Put_message("You must enter a non-negative number.");
+           continue;
+       }
+       for (tmpelem = top, i = dst;
+            i-- > 1 && tmpelem->q_forw;
+            tmpelem = tmpelem->q_forw);
+       if (i > 0) {
+           Put_message("You entered a number that is too high");
+           continue;
+       }
+       break;
     }
     args[2] = SortAfter(top, dst);
     args[0] = argv[1];
This page took 0.044171 seconds and 5 git commands to generate.