X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Flustre_rsync.c;h=a54ac2578ad4a93b1805c5b9bad210061ec03a47;hb=39fad9dc60ddd30bdfe165b40927e19f38b76428;hp=7e971373e943b4ae96f96d92a67987873f4dad2e;hpb=361edea4707254f4752ffd8c2db6c77a3ab9539c;p=fs%2Flustre-release.git diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index 7e97137..a54ac25 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -23,7 +23,7 @@ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, 2016, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -120,14 +120,11 @@ #include #include #include -#include -#include #include -#include -#include #include #include "lustre_rsync.h" +#include "callvpe.h" #define REPLICATE_STATUS_VER 1 #define CLEAR_INTERVAL 100 @@ -144,9 +141,6 @@ #define DINFO 1 #define DTRACE 2 -/* Not used; declared for fulfilling obd.c's dependency. */ -command_t cmdlist[0]; - /* Information for processing a changelog record. This structure is allocated on the heap instead of allocating large variables on the stack. */ @@ -161,13 +155,12 @@ struct lr_info { char spfid[LR_FID_STR_LEN]; char sname[NAME_MAX + 1]; char name[NAME_MAX + 1]; - char src[PATH_MAX + 1]; - char dest[PATH_MAX + 1]; + char src[3 * PATH_MAX + 1]; + char dest[3 * PATH_MAX + 1]; char path[PATH_MAX + 1]; char savedpath[PATH_MAX + 1]; char link[PATH_MAX + 1]; char linktmp[PATH_MAX + 1]; - char cmd[PATH_MAX]; int bufsize; char *buf; @@ -241,16 +234,6 @@ void lr_usage() "\t--dry-run don't write anything\n"); } -#define DEBUG_ENTRY(info) \ - lr_debug(D_TRACE, "***** Start %lld %s (%d) %s %s %s *****\n", \ - (info)->recno, changelog_type2str((info)->type), \ - (info)->type, (info)->tfid, (info)->pfid, (info)->name); - -#define DEBUG_EXIT(info, rc) \ - lr_debug(D_TRACE, "##### End %lld %s (%d) %s %s %s rc=%d #####\n", \ - (info)->recno, changelog_type2str((info)->type), \ - (info)->type, (info)->tfid, (info)->pfid, (info)->name, rc); - /* Print debug information. This is controlled by the value of the global variable 'debug' */ void lr_debug(int level, const char *fmt, ...) @@ -283,9 +266,8 @@ void * lr_grow_buf(void *buf, int size) /* Use rsync to replicate file data */ int lr_rsync_data(struct lr_info *info) { - int rc; - struct stat st_src, st_dest; - char cmd[PATH_MAX]; + struct stat st_src, st_dest; + int rc; lr_debug(DTRACE, "Syncing data%s\n", info->tfid); @@ -307,18 +289,28 @@ int lr_rsync_data(struct lr_info *info) if (st_src.st_mtime != st_dest.st_mtime || st_src.st_size != st_dest.st_size) { - /* XXX spawning off an rsync for every data sync and - * waiting synchronously is bad for performance. - * librsync could possibly used here. But it does not - * seem to be of production grade. Multi-threaded - * replication is also to be considered. - */ - int status; - snprintf(cmd, PATH_MAX, "%s --inplace %s %s", rsync, info->src, - info->dest); - lr_debug(DTRACE, "\t%s %s\n", cmd, info->tfid); - status = system(cmd); - if (status == -1) { + /* XXX spawning off an rsync for every data sync and + * waiting synchronously is bad for performance. + * librsync could possibly used here. But it does not + * seem to be of production grade. Multi-threaded + * replication is also to be considered. + */ + char *args[] = { + rsync, + "--inplace", + "--", + info->src, + info->dest, + NULL, + }; + extern char **environ; + int status; + + lr_debug(DTRACE, "\t%s %s %s %s %s %s\n", args[0], args[1], + args[2], args[3], args[4], info->tfid); + + status = callvpe(rsync, args, environ); + if (status < 0) { rc = -errno; } else if (WIFEXITED(status)) { status = WEXITSTATUS(status); @@ -573,14 +565,15 @@ int lr_get_symlink(struct lr_info *info) strlen(status->ls_source)) == 0) { /* Strip source fs path and replace with target fs path. */ link = info->linktmp + strlen(status->ls_source); - snprintf(info->src, PATH_MAX, "%s%s", + snprintf(info->src, sizeof(info->src), "%s%s", status->ls_targets[info->target_no], link); link = info->src; } else { link = info->linktmp; } - strlcpy(info->link, link, sizeof(info->link)); - + rc = snprintf(info->link, sizeof(info->link), "%s", link); + if (rc >= sizeof(info->link)) + rc = -E2BIG; return rc; } @@ -648,13 +641,16 @@ int lr_add_pc(const char *pfid, const char *tfid, const char *name) p = calloc(1, sizeof(*p)); if (p == NULL) return -ENOMEM; - len = strlcpy(p->pc_log.pcl_pfid, pfid, sizeof(p->pc_log.pcl_pfid)); + len = snprintf(p->pc_log.pcl_pfid, sizeof(p->pc_log.pcl_pfid), + "%s", pfid); if (len >= sizeof(p->pc_log.pcl_pfid)) goto out_err; - len = strlcpy(p->pc_log.pcl_tfid, tfid, sizeof(p->pc_log.pcl_tfid)); + len = snprintf(p->pc_log.pcl_tfid, sizeof(p->pc_log.pcl_tfid), + "%s", tfid); if (len >= sizeof(p->pc_log.pcl_tfid)) goto out_err; - len = strlcpy(p->pc_log.pcl_name, name, sizeof(p->pc_log.pcl_name)); + len = snprintf(p->pc_log.pcl_name, sizeof(p->pc_log.pcl_name), + "%s", name); if (len >= sizeof(p->pc_log.pcl_name)) goto out_err; @@ -670,18 +666,22 @@ out_err: void lr_cascade_move(const char *fid, const char *dest, struct lr_info *info) { struct lr_parent_child_list *curr, *prev; - char *d; + char d[4 * PATH_MAX + 1]; int rc; - d = calloc(1, PATH_MAX + 1); prev = curr = parents; while (curr) { if (strcmp(curr->pc_log.pcl_pfid, fid) == 0) { - snprintf(d, PATH_MAX, "%s/%s", dest, - curr->pc_log.pcl_name); - snprintf(info->src, PATH_MAX, "%s/%s/%s", - status->ls_targets[info->target_no], - SPECIAL_DIR, curr->pc_log.pcl_tfid); + if (snprintf(d, sizeof(d), "%s/%s", dest, + curr->pc_log.pcl_name) >= sizeof(d)) { + fprintf(stderr, "Buffer truncated\n"); + return; + } + if (snprintf(info->src, sizeof(info->src), "%s/%s/%s", + status->ls_targets[info->target_no], + SPECIAL_DIR, curr->pc_log.pcl_tfid) >= + sizeof(info->src)) + return; rc = rename(info->src, d); if (rc == -1) { fprintf(stderr, "Error renaming file " @@ -702,8 +702,6 @@ void lr_cascade_move(const char *fid, const char *dest, struct lr_info *info) curr = curr->pc_next; } } - - free(d); } /* remove [info->spfid, info->sfid] from parents */ @@ -730,7 +728,7 @@ int lr_mk_special(struct lr_info *info) { int rc; - snprintf(info->dest, PATH_MAX, "%s/%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s/%s", status->ls_targets[info->target_no], SPECIAL_DIR, info->tfid); @@ -759,14 +757,26 @@ int lr_rmfile(struct lr_info *info) /* Recursively remove directory and its contents */ int lr_rm_recursive(struct lr_info *info) { - int rc; - - snprintf(info->cmd, PATH_MAX, "rm -rf %s", info->dest); - rc = system(info->cmd); - if (rc == -1) - rc = -errno; + char *args[] = { + "rm", + "-rf", + "--", + info->dest, + NULL, + }; + extern char **environ; + int status; + int rc; + + status = callvpe("/bin/rm", args, environ); + if (status < 0) + rc = -errno; + else if (WIFEXITED(status)) + rc = WEXITSTATUS(status) == 0 ? 0 : -EINVAL; + else + rc = -EINTR; - return rc; + return rc; } /* Remove a file under SPECIAL_DIR with its tfid as its name. */ @@ -774,7 +784,7 @@ int lr_rm_special(struct lr_info *info) { int rc; - snprintf(info->dest, PATH_MAX, "%s/%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s/%s", status->ls_targets[info->target_no], SPECIAL_DIR, info->tfid); rc = lr_rmfile(info); @@ -818,11 +828,13 @@ int lr_create(struct lr_info *info) /* Is f2p(pfid)+name != f2p(tfid)? If not the file has moved. */ len = strlen(info->path); if (len == 1 && info->path[0] == '/') - snprintf(info->dest, PATH_MAX, "%s", info->name); + snprintf(info->dest, sizeof(info->dest), "%s", info->name); else if (len - 1 > 0 && info->path[len - 1] == '/') - snprintf(info->dest, PATH_MAX, "%s%s", info->path, info->name); + snprintf(info->dest, sizeof(info->dest), "%s%s", info->path, + info->name); else - snprintf(info->dest, PATH_MAX, "%s/%s", info->path, info->name); + snprintf(info->dest, sizeof(info->dest), "%s/%s", info->path, + info->name); lr_debug(DTRACE, "dest = %s; savedpath = %s\n", info->dest, info->savedpath); @@ -835,8 +847,8 @@ int lr_create(struct lr_info *info) /* Is f2p(pfid) present on the target? If not, the parent has moved */ if (!mkspecial) { - snprintf(info->dest, PATH_MAX, "%s/%s", status->ls_targets[0], - info->path); + snprintf(info->dest, sizeof(info->dest), "%s/%s", + status->ls_targets[0], info->path); if (access(info->dest, F_OK) != 0) { lr_debug(DTRACE, "create: parent %s not found\n", info->dest); @@ -845,10 +857,10 @@ int lr_create(struct lr_info *info) } for (info->target_no = 0; info->target_no < status->ls_num_targets; info->target_no++) { - snprintf(info->dest, PATH_MAX, "%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s", status->ls_targets[info->target_no], info->savedpath); lr_get_FID_PATH(status->ls_source, info->tfid, info->src, - PATH_MAX); + PATH_MAX); if (!mkspecial) rc1 = lr_mkfile(info); @@ -884,7 +896,7 @@ int lr_remove(struct lr_info *info) rc = rc1; continue; } - snprintf(info->dest, PATH_MAX, "%s/%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s/%s", status->ls_targets[info->target_no], info->path, info->name); @@ -927,21 +939,22 @@ int lr_move(struct lr_info *info) info->target_no++) { if (!rc_dest) { - snprintf(info->dest, PATH_MAX, "%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s", status->ls_targets[info->target_no], info->path); if (access(info->dest, F_OK) != 0) { rc_dest = -errno; } else { - snprintf(info->dest, PATH_MAX, "%s/%s/%s", - status->ls_targets[info->target_no], - info->path, info->name); + snprintf(info->dest, sizeof(info->dest), + "%s/%s/%s", + status->ls_targets[info->target_no], + info->path, info->name); } lr_debug(DINFO, "dest path %s rc_dest=%d\n", info->dest, rc_dest); } if (rc_dest == -ENOENT) { - snprintf(info->dest, PATH_MAX, "%s/%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s/%s", status->ls_targets[info->target_no], SPECIAL_DIR, info->sfid); special_dest = 1; @@ -949,7 +962,7 @@ int lr_move(struct lr_info *info) } if (!rc_src) { - snprintf(info->src, PATH_MAX, "%s/%s/%s", + snprintf(info->src, sizeof(info->src), "%s/%s/%s", status->ls_targets[info->target_no], srcpath, info->sname); lr_debug(DINFO, "src path %s rc_src=%d\n", info->src, @@ -957,7 +970,7 @@ int lr_move(struct lr_info *info) } if (rc_src == -ENOENT || (access(info->src, F_OK) != 0 && errno == ENOENT)) { - snprintf(info->src, PATH_MAX, "%s/%s/%s", + snprintf(info->src, sizeof(info->src), "%s/%s/%s", status->ls_targets[info->target_no], SPECIAL_DIR, info->sfid); special_src = 1; @@ -1028,6 +1041,8 @@ int lr_link(struct lr_info *info) /* Search through the hardlinks to get the src */ for (i = 0; i < st.st_nlink && info->src[0] == 0; i++) { + size_t len; + rc1 = lr_get_path_ln(info, info->tfid, i); lr_debug(rc1 ? 0:DTRACE, "\tfid2path %s, %s, %d rc=%d\n", info->path, info->name, i, rc1); @@ -1038,14 +1053,17 @@ int lr_link(struct lr_info *info) * Compare the path of target FID with info->dest * to find out info->src. */ - char srcpath[PATH_MAX]; + len = sizeof(status->ls_targets[info->target_no]) + + sizeof(info->path); + char srcpath[len + 1]; snprintf(srcpath, sizeof(srcpath), "%s/%s", status->ls_targets[info->target_no], info->path); if (strcmp(srcpath, info->dest) != 0) { - strlcpy(info->src, srcpath, sizeof(info->src)); + snprintf(info->src, sizeof(info->src), "%s", + srcpath); lr_debug(DINFO, "link source is %s\n", info->src); } @@ -1057,11 +1075,11 @@ int lr_link(struct lr_info *info) } if (info->src[0] == 0) - snprintf(info->src, PATH_MAX, "%s/%s/%s", + snprintf(info->src, sizeof(info->src), "%s/%s/%s", status->ls_targets[info->target_no], SPECIAL_DIR, info->tfid); else if (info->dest[0] == 0) - snprintf(info->dest, PATH_MAX, "%s/%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s/%s", status->ls_targets[info->target_no], SPECIAL_DIR, info->tfid); @@ -1094,7 +1112,7 @@ int lr_setattr(struct lr_info *info) for (info->target_no = 0; info->target_no < status->ls_num_targets; info->target_no++) { - snprintf(info->dest, PATH_MAX, "%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s", status->ls_targets[info->target_no], info->path); lr_debug(DINFO, "setattr: %s %s %s", info->src, info->dest, info->tfid); @@ -1125,7 +1143,7 @@ int lr_setxattr(struct lr_info *info) for (info->target_no = 0; info->target_no < status->ls_num_targets; info->target_no++) { - snprintf(info->dest, PATH_MAX, "%s/%s", + snprintf(info->dest, sizeof(info->dest), "%s/%s", status->ls_targets[info->target_no], info->path); lr_debug(DINFO, "setxattr: %s %s %s\n", info->src, info->dest, info->tfid); @@ -1158,7 +1176,7 @@ int lr_parse_line(void *priv, struct lr_info *info) namelen = strnlen(changelog_rec_name(rec), rec->cr_namelen); if (copylen > namelen + 1) copylen = namelen + 1; - strlcpy(info->name, changelog_rec_name(rec), copylen); + snprintf(info->name, copylen, "%s", changelog_rec_name(rec)); /* Don't use rnm if CLF_RENAME isn't set */ rnm = changelog_rec_rename(rec); @@ -1172,7 +1190,7 @@ int lr_parse_line(void *priv, struct lr_info *info) namelen = changelog_rec_snamelen(rec); if (copylen > namelen + 1) copylen = namelen + 1; - strlcpy(info->sname, changelog_rec_sname(rec), copylen); + snprintf(info->sname, copylen, "%s", changelog_rec_sname(rec)); if (verbose > 1) printf("Rec %lld: %d %s %s\n", info->recno, info->type, @@ -1212,7 +1230,7 @@ void lr_backup_log() if (logbackedup) return; - snprintf(backupfile, PATH_MAX, "%s.old", statuslog); + snprintf(backupfile, sizeof(backupfile), "%s.old", statuslog); (void) rename(statuslog, backupfile); logbackedup = 1; @@ -1346,20 +1364,24 @@ int lr_read_log() status->ls_last_recno = s->ls_last_recno; if (status->ls_registration[0] == '\0') - strlcpy(status->ls_registration, s->ls_registration, - sizeof(status->ls_registration)); + snprintf(status->ls_registration, + sizeof(status->ls_registration), "%s", + s->ls_registration); if (status->ls_mdt_device[0] == '\0') - strlcpy(status->ls_mdt_device, s->ls_mdt_device, - sizeof(status->ls_mdt_device)); + snprintf(status->ls_mdt_device, + sizeof(status->ls_mdt_device), "%s", + s->ls_mdt_device); if (status->ls_source_fs[0] == '\0') - strlcpy(status->ls_source_fs, s->ls_source_fs, - sizeof(status->ls_source_fs)); + snprintf(status->ls_source_fs, + sizeof(status->ls_source_fs), "%s", + s->ls_source_fs); if (status->ls_source[0] == '\0') - strlcpy(status->ls_source, s->ls_source, - sizeof(status->ls_source)); + snprintf(status->ls_source, + sizeof(status->ls_source), "%s", + s->ls_source); out: if (fd != -1) @@ -1374,37 +1396,33 @@ int lr_read_log() int lr_clear_cl(struct lr_info *info, int force) { char mdt_device[LR_NAME_MAXLEN + 1]; - long long rec; int rc = 0; if (force || info->recno > status->ls_last_recno + CLEAR_INTERVAL) { - if (info->type == CL_RENAME) - rec = info->recno + 1; - else - rec = info->recno; if (!noclear && !dryrun) { /* llapi_changelog_clear modifies the mdt * device name so make a copy of it until this * is fixed. - */ - strlcpy(mdt_device, status->ls_mdt_device, - sizeof(mdt_device)); + */ + snprintf(mdt_device, sizeof(mdt_device), "%s", + status->ls_mdt_device); rc = llapi_changelog_clear(mdt_device, status->ls_registration, - rec); + info->recno); if (rc) - printf("Changelog clear (%s, %s, %lld) " - "returned %d\n", status->ls_mdt_device, - status->ls_registration, rec, rc); - } - if (!rc && !dryrun) { - status->ls_last_recno = rec; - lr_write_log(); + printf("Changelog clear (%s, %s, %lld) " + "returned %d\n", status->ls_mdt_device, + status->ls_registration, info->recno, + rc); + } - } - } + if (!rc && !dryrun) { + status->ls_last_recno = info->recno; + lr_write_log(); + } + } - return rc; + return rc; } /* Locate a usable version of rsync. At this point we'll use any @@ -1415,12 +1433,12 @@ int lr_locate_rsync() int len; /* Locate rsync */ - snprintf(rsync, PATH_MAX, "%s -p %s", TYPE, RSYNC); + snprintf(rsync, sizeof(rsync), "%s -p %s", TYPE, RSYNC); fp = popen(rsync, "r"); if (fp == NULL) return -1; - if (fgets(rsync, PATH_MAX, fp) == NULL) { + if (fgets(rsync, sizeof(rsync), fp) == NULL) { fclose(fp); return -1; } @@ -1431,12 +1449,12 @@ int lr_locate_rsync() fclose(fp); /* Determine the version of rsync */ - snprintf(rsync_ver, PATH_MAX, "%s --version", rsync); + snprintf(rsync_ver, sizeof(rsync_ver), "%s --version", rsync); fp = popen(rsync_ver, "r"); if (fp == NULL) return -1; - if (fgets(rsync_ver, PATH_MAX, fp) == NULL) { + if (fgets(rsync_ver, sizeof(rsync_ver), fp) == NULL) { fclose(fp); return -1; } @@ -1506,9 +1524,18 @@ int lr_replicate() "mountpoint.\n"); goto out; } - if (status->ls_mdt_device[0] == '\0') - snprintf(status->ls_mdt_device, LR_NAME_MAXLEN, "%s%s", - status->ls_source_fs, DEFAULT_MDT); + + if (status->ls_mdt_device[0] == '\0') { + int len; + + len = snprintf(status->ls_mdt_device, + sizeof(status->ls_mdt_device), "%s%s", + status->ls_source_fs, DEFAULT_MDT); + if (len >= sizeof(status->ls_mdt_device)) { + rc = -E2BIG; + goto out; + } + } ext = calloc(1, sizeof(struct lr_info)); if (ext == NULL) { @@ -1517,8 +1544,8 @@ int lr_replicate() } for (i = 0, xattr_not_supp = 0; i < status->ls_num_targets; i++) { - snprintf(info->dest, PATH_MAX, "%s/%s", status->ls_targets[i], - SPECIAL_DIR); + snprintf(info->dest, sizeof(info->dest), "%s/%s", + status->ls_targets[i], SPECIAL_DIR); rc = mkdir(info->dest, 0777); if (rc == -1 && errno != EEXIST) { fprintf(stderr, "Error writing to target path %s.\n", @@ -1552,7 +1579,10 @@ int lr_replicate() } rc = llapi_changelog_set_xflags(changelog_priv, - CHANGELOG_EXTRA_FLAG_UIDGID); + CHANGELOG_EXTRA_FLAG_UIDGID | + CHANGELOG_EXTRA_FLAG_NID | + CHANGELOG_EXTRA_FLAG_OMODE | + CHANGELOG_EXTRA_FLAG_XATTR); if (rc < 0) { fprintf(stderr, "Error setting xflag in changelog for fs %s.\n", status->ls_source_fs); @@ -1572,15 +1602,20 @@ int lr_replicate() memcpy(info->spfid, info->pfid, sizeof(info->spfid)); memcpy(info->tfid, ext->tfid, sizeof(info->tfid)); memcpy(info->pfid, ext->pfid, sizeof(info->pfid)); - strlcpy(info->sname, info->name, sizeof(info->sname)); - strlcpy(info->name, ext->name, sizeof(info->name)); + snprintf(info->sname, sizeof(info->sname), "%s", + info->name); + snprintf(info->name, sizeof(info->name), "%s", + ext->name); info->is_extended = 1; + info->recno = ext->recno; /* For lr_clear_cl(). */ } if (dryrun) continue; - DEBUG_ENTRY(info); + lr_debug(DTRACE, "***** Start %lld %s (%d) %s %s %s *****\n", + info->recno, changelog_type2str(info->type), + info->type, info->tfid, info->pfid, info->name); switch(info->type) { case CL_CREATE: @@ -1603,12 +1638,14 @@ int lr_replicate() case CL_SETATTR: rc = lr_setattr(info); break; - case CL_XATTR: + case CL_SETXATTR: rc = lr_setxattr(info); break; case CL_CLOSE: case CL_EXT: case CL_OPEN: + case CL_GETXATTR: + case CL_DN_OPEN: case CL_LAYOUT: case CL_MARK: /* Nothing needs to be done for these entries */ @@ -1616,7 +1653,11 @@ int lr_replicate() default: break; } - DEBUG_EXIT(info, rc); + + lr_debug(DTRACE, "##### End %lld %s (%d) %s %s %s rc=%d #####\n", + info->recno, changelog_type2str(info->type), + info->type, info->tfid, info->pfid, info->name, rc); + if (rc && rc != -ENOENT) { lr_print_failure(info, rc); errors++; @@ -1624,10 +1665,6 @@ int lr_replicate() break; } lr_clear_cl(info, 0); - if (debug) { - bzero(info, sizeof(struct lr_info)); - bzero(ext, sizeof(struct lr_info)); - } } llapi_changelog_fini(&changelog_priv); @@ -1680,8 +1717,8 @@ int main(int argc, char *argv[]) break; case 's': /* Assume absolute paths */ - strlcpy(status->ls_source, optarg, - sizeof(status->ls_source)); + snprintf(status->ls_source, sizeof(status->ls_source), + "%s", optarg); break; case 't': status->ls_num_targets++; @@ -1702,16 +1739,18 @@ int main(int argc, char *argv[]) if (status == NULL) return -ENOMEM; } - strlcpy(status->ls_targets[status->ls_num_targets - 1], - optarg, sizeof(status->ls_targets[0])); + snprintf(status->ls_targets[status->ls_num_targets - 1], + sizeof(status->ls_targets[0]), "%s", optarg); break; case 'm': - strlcpy(status->ls_mdt_device, optarg, - sizeof(status->ls_mdt_device)); + snprintf(status->ls_mdt_device, + sizeof(status->ls_mdt_device), + "%s", optarg); break; case 'u': - strlcpy(status->ls_registration, optarg, - sizeof(status->ls_registration)); + snprintf(status->ls_registration, + sizeof(status->ls_registration), + "%s", optarg); break; case 'l': statuslog = optarg; @@ -1801,10 +1840,6 @@ int main(int argc, char *argv[]) return -1; } - /* This plumbing is needed for some of the ioctls behind - llapi calls to work. */ - register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH); - rc = lr_locate_rsync(); if (use_rsync && rc != 0) { fprintf(stderr, "Error: unable to locate %s.\n", RSYNC);