]> mj.ucw.cz Git - libucw.git/blobdiff - lib/bucket.c
If have GET_O and GET_P, we should have PUT_O and PUT_P as well.
[libucw.git] / lib / bucket.c
index 38d552e0c44d0ed2016d73371ac8241d6091264b..e35f99f8cc011805f6a000ad724eeb3aa6a07ff4 100644 (file)
@@ -349,27 +349,29 @@ obuck_shakedown(int (*kibitz)(struct obuck_header *old, oid_t new, byte *buck))
        goto reread;
       if (GET_U32(rbuf + roff + l - 4) != OBUCK_TRAILER)
        obuck_broken("missing trailer during shakedown");
-      if (rhdr->oid != OBUCK_OID_DELETED &&
-         kibitz(rhdr, w_bucket_start >> OBUCK_SHIFT, (byte *)(rhdr+1)))
+      if (rhdr->oid != OBUCK_OID_DELETED)
        {
-         if (bucket_start == w_bucket_start)
+         if (kibitz(rhdr, w_bucket_start >> OBUCK_SHIFT, (byte *)(rhdr+1)))
            {
-             /* No copying needed now nor ever in the past, hence woff==0 */
-             wstart += l;
-           }
-         else
-           {
-             if (obuck_shake_buflen - woff < l)
+             if (bucket_start == w_bucket_start)
+               {
+                 /* No copying needed now nor ever in the past, hence woff==0 */
+                 wstart += l;
+               }
+             else
                {
-                 if (sh_pwrite(obuck_fd, wbuf, woff, wstart) != woff)
-                   die("obuck_shakedown write failed: %m");
-                 wstart += woff;
-                 woff = 0;
+                 if (obuck_shake_buflen - woff < l)
+                   {
+                     if (sh_pwrite(obuck_fd, wbuf, woff, wstart) != woff)
+                       die("obuck_shakedown write failed: %m");
+                     wstart += woff;
+                     woff = 0;
+                   }
+                 whdr = (struct obuck_header *)(wbuf+woff);
+                 memcpy(whdr, rhdr, l);
+                 whdr->oid = w_bucket_start >> OBUCK_SHIFT;
+                 woff += l;
                }
-             whdr = (struct obuck_header *)(wbuf+woff);
-             memcpy(whdr, rhdr, l);
-             whdr->oid = w_bucket_start >> OBUCK_SHIFT;
-             woff += l;
            }
        }
       else
@@ -428,7 +430,10 @@ int main(int argc, char **argv)
   log_init(NULL);
   if (cf_getopt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) >= 0 ||
       optind < argc)
-    die("This program supports only the following command-line arguments:\n" CF_USAGE);
+  {
+    fputs("This program supports only the following command-line arguments:\n" CF_USAGE, stderr);
+    exit(1);
+  }
 
   unlink(obuck_name);
   obuck_init(1);