Whamcloud - gitweb
Reinitialize optind to 0 on each lfs_* call, in case lfs is being used interactively...
authorkalpak <kalpak>
Mon, 12 May 2008 11:32:27 +0000 (11:32 +0000)
committerkalpak <kalpak>
Mon, 12 May 2008 11:32:27 +0000 (11:32 +0000)
 b=15212
 i=rupesh
 i=johann

lustre/ChangeLog
lustre/tests/sanity.sh
lustre/utils/lfs.c

index 600acb0..47cc74f 100644 (file)
@@ -987,6 +987,10 @@ Description: eliminate client locks in face of contention
 Details    : file contention detection and lockless i/o implementation
              for contended files.
 
+Severity   : normal
+Bugzilla   : 15212
+Description: Reinitialize optind to 0 so that interactive lfs works in all cases
+
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
index b797662..691e47f 100644 (file)
@@ -4935,6 +4935,19 @@ test_127() { # bug 15521
 }
 run_test 127 "verify the client stats are sane"
 
+test_128() { # bug 15212
+       touch $DIR/$tfile
+       $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
+               find $DIR/$tfile
+               find $DIR/$tfile
+       EOF
+
+       result=$(grep error $TMP/$tfile.log)
+       rm -f $DIR/$tfile
+       [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
+}
+run_test 128 "interactive lfs for 2 consecutive find's"
+
 TMPDIR=$OLDTMPDIR
 TMP=$OLDTMP
 HOME=$OLDHOME
index 94454d6..8758601 100644 (file)
@@ -214,9 +214,9 @@ static int lfs_setstripe(int argc, char **argv)
                 stripe_count_arg = argv[4];
                 optind = 4;
         } else {
+                optind = 0;
                 while ((c = getopt_long(argc, argv, "c:di:s:",
-                                                long_opts, NULL)) >= 0) 
-                {
+                                                long_opts, NULL)) >= 0) {
                         switch (c) {
                         case 0:
                                 /* Long options. */
@@ -362,6 +362,7 @@ static int lfs_find(int argc, char **argv)
 
         time(&t);
 
+        optind = 0;
         while ((c = getopt_long_only(argc, argv, "-A:C:D:M:n:PpO:qrs:t:v",
                                      long_opts, NULL)) >= 0) {
                 xtime = NULL;
@@ -1084,6 +1085,7 @@ static int lfs_quotachown(int argc, char **argv)
         int c,rc;
         int flag = 0;
 
+        optind = 0;
         while ((c = getopt(argc, argv, "i")) != -1) {
                 switch (c) {
                 case 'i':