From 064fd16440eec14550a681a8957d6b749c9ef049 Mon Sep 17 00:00:00 2001 From: kalpak Date: Mon, 12 May 2008 11:31:05 +0000 Subject: [PATCH] Reinitialize optind to 0 on each lfs_* call, in case lfs is being used interactively. Most lfs_* functions do this already, but a few (find, setstripe, quotachown) do not. b=15212 i=rupesh i=johann --- lustre/ChangeLog | 4 ++++ lustre/tests/sanity.sh | 13 +++++++++++++ lustre/utils/lfs.c | 6 ++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 5051a49..020b17d 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -49,6 +49,10 @@ Description: Don't update lov_desc members until making sure they are valid Details : When updating lov_desc members via proc fs, need fix their validities before doing the real update. +Severity : normal +Bugzilla : 15212 +Description: Reinitialize optind to 0 so that interactive lfs works in all cases + ------------------------------------------------------------------------------- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 79c51be..c5cdfd4 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -4911,6 +4911,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 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index dba6a47..aaba0b2 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -188,9 +188,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. */ @@ -337,6 +337,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; @@ -1060,6 +1061,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': -- 1.8.3.1