Fix fs storebehind on files with 2 or more servers
authorSimon Wilkinson <sxw@your-file-system.com>
Wed, 3 Feb 2010 00:37:20 +0000 (00:37 +0000)
committerDerrick Brashear <shadow|account-1000005@unknown>
Wed, 3 Feb 2010 21:29:57 +0000 (13:29 -0800)
fs storebehind didn't allocate a large enough buffer for its call
to VIOCWHERIS. This meant that when it was called on a file with
more than one server (one in a readonly volume), it would error
out with E2BIG, rather than a more appropriate message.

Fix this, by using the generic 'space' buffer for the VIOCWHERIS
call.

Change-Id: Ida0d40175f07ad528720ca700db5b5027b975095
Reviewed-on: http://gerrit.openafs.org/1224
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/venus/fs.c

index b28d819..cc394f0 100644 (file)
@@ -3276,13 +3276,14 @@ StoreBehindCmd(struct cmd_syndesc *as, void *arock)
        verbose = 1;
 
     blob.in = (char *)&tsb;
-    blob.out = (char *)&tsb2;
-    blob.in_size = blob.out_size = sizeof(struct sbstruct);
-    memset(&tsb2, 0, sizeof(tsb2));
+    blob.in_size = sizeof(struct sbstruct);
 
     /* once per -file */
     for (ti = as->parms[1].items; ti; ti = ti->next) {
        /* Do this solely to see if the file is there */
+
+        blob.out = space;
+       blob.out_size = AFS_PIOCTL_MAXSIZE;
        code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
        if (code) {
            Die(errno, ti->data);
@@ -3290,6 +3291,9 @@ StoreBehindCmd(struct cmd_syndesc *as, void *arock)
            continue;
        }
 
+       memset(&tsb2, 0, sizeof(tsb2));
+       blob.out = (char *)&tsb2;
+       blob.out_size = sizeof(struct sbstruct);
        code = pioctl(ti->data, VIOC_STORBEHIND, &blob, 1);
        if (code) {
            Die(errno, ti->data);
@@ -3314,6 +3318,9 @@ StoreBehindCmd(struct cmd_syndesc *as, void *arock)
      */
     if (!as->parms[1].items || (allfiles != -1)) {
        tsb.sb_default = allfiles;
+        memset(&tsb2, 0, sizeof(tsb2));
+       blob.out = (char *)&tsb2;
+       blob.out_size = sizeof(struct sbstruct);
        code = pioctl(0, VIOC_STORBEHIND, &blob, 1);
        if (code) {
            Die(errno, ((allfiles == -1) ? 0 : "-allfiles"));