Whamcloud - gitweb
LU-6210 utils: Use C99 struct initializer in lustre_rsync.c
[fs/lustre-release.git] / lustre / utils / lustre_rsync.c
index c3eab0f..361d2ad 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  *      [pfid,tfid,name] tracked from (1) is used for this.
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <utime.h>
 #include <time.h>
 #include <sys/xattr.h>
+#include <linux/types.h>
 
+#include <libcfs/libcfs_debug.h>
 #include <libcfs/util/string.h>
 #include <libcfs/util/parser.h>
 #include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
 #include "lustre_rsync.h"
 
 #define REPLICATE_STATUS_VER 1
@@ -208,24 +206,24 @@ FILE *debug_log;
 
 /* Command line options */
 struct option long_opts[] = {
-        {"source",      required_argument, 0, 's'},
-        {"target",      required_argument, 0, 't'},
-        {"mdt",         required_argument, 0, 'm'},
-        {"user",        required_argument, 0, 'u'},
-        {"statuslog",   required_argument, 0, 'l'},
-        {"verbose",     no_argument,       0, 'v'},
-        {"xattr",       required_argument, 0, 'x'},
-        {"dry-run",     no_argument,       0, 'z'},
-        /* Undocumented options follow */
-        {"cl-clear",    required_argument, 0, 'c'},
-        {"use-rsync",   no_argument,       0, 'r'},
-        {"rsync-threshold", required_argument, 0, 'y'},
-        {"start-recno", required_argument, 0, 'n'},
-        {"abort-on-err",no_argument,       0, 'a'},
-        {"debug",       required_argument, 0, 'd'},
-       {"debuglog",    required_argument, 0, 'D'},
-       {0, 0, 0, 0}
-};
+       { .val = 'l',   .name = "statuslog",    .has_arg = required_argument },
+       { .val = 'm',   .name = "mdt",          .has_arg = required_argument },
+       { .val = 's',   .name = "source",       .has_arg = required_argument },
+       { .val = 't',   .name = "target",       .has_arg = required_argument },
+       { .val = 'u',   .name = "user",         .has_arg = required_argument },
+       { .val = 'v',   .name = "verbose",      .has_arg = no_argument },
+       { .val = 'x',   .name = "xattr",        .has_arg = required_argument },
+       { .val = 'z',   .name = "dry-run",      .has_arg = no_argument },
+       /* Undocumented options follow */
+       { .val = 'a',   .name = "abort-on-err", .has_arg = no_argument },
+       { .val = 'c',   .name = "cl-clear",     .has_arg = required_argument },
+       { .val = 'd',   .name = "debug",        .has_arg = required_argument },
+       { .val = 'D',   .name = "debuglog",     .has_arg = required_argument },
+       { .val = 'n',   .name = "start-recno",  .has_arg = required_argument },
+       { .val = 'r',   .name = "use-rsync",    .has_arg = no_argument },
+       { .val = 'y',   .name = "rsync-threshold",
+                                               .has_arg = required_argument },
+       { .name = NULL } };
 
 /* Command line usage */
 void lr_usage()
@@ -612,8 +610,13 @@ int lr_mkfile(struct lr_info *info)
         } else {
                 rc = mknod(info->dest, S_IFREG | 0777, 0);
         }
-        if (rc)
-                return -errno;
+
+       if (rc < 0) {
+               if (errno == EEXIST)
+                       rc = 0;
+               else
+                       return -errno;
+       }
 
         /* Sync data and attributes */
         if (info->type == CL_CREATE || info->type == CL_MKDIR) {
@@ -908,7 +911,7 @@ int lr_move(struct lr_info *info)
         int special_dest = 0;
        char srcpath[PATH_MAX + 1] = "";
 
-       LASSERT(info->is_extended);
+       assert(info->is_extended);
 
        rc_src = lr_get_path(info, info->spfid);
        if (rc_src < 0 && rc_src != -ENOENT)