int debug = 0;
int verbose = 0;
int nomtab = 0;
+static char *progname = NULL;
static void
update_mtab_entry(char *spec, char *node, char *type, char *opts,
if (!nomtab) {
fp = setmntent(MOUNTED, "a+");
if (fp == NULL) {
- fprintf(stderr, "setmntent(%s): %s:", MOUNTED,
- strerror (errno));
+ fprintf(stderr, "%s: setmntent(%s): %s:",
+ progname, MOUNTED, strerror (errno));
} else {
if ((addmntent (fp, &mnt)) == 1) {
- fprintf(stderr, "addmntent: %s:",
- strerror (errno));
+ fprintf(stderr, "%s: addmntent: %s:",
+ progname, strerror (errno));
}
endmntent(fp);
}
lmd->lmd_nal = ptl_name2nal(opteq+1);
} else if(!strcmp(opt, "local_nid")) {
if (ptl_parse_nid(&nid, opteq+1) != 0) {
- fprintf (stderr, "mount: "
+ fprintf (stderr, "%s: "
"can't parse NID %s\n",
+ progname,
opteq+1);
return (-1);
}
lmd->lmd_local_nid = nid;
} else if(!strcmp(opt, "server_nid")) {
if (ptl_parse_nid(&nid, opteq+1) != 0) {
- fprintf (stderr, "mount: "
+ fprintf (stderr, "%s: "
"can't parse NID %s\n",
- opteq+1);
+ progname, opteq+1);
return (-1);
}
lmd->lmd_server_nid = nid;
if (lmd->lmd_nal == SOCKNAL || lmd->lmd_nal == TCPNAL) {
rc = gethostname(buf, sizeof(buf) - 1);
if (rc) {
- fprintf (stderr, "mount: can't get local buf:"
- "%d\n", rc);
+ fprintf (stderr, "%s: can't get local buf: %d\n",
+ progname, rc);
return rc;
}
} else if (lmd->lmd_nal == QSWNAL) {
} while (rc != 0 && pfiles[++i] != NULL);
if (rc != 0) {
- fprintf(stderr,
- "mount: can't read Elan ID from /proc\n");
+ fprintf(stderr, "%s: can't read Elan ID from /proc\n",
+ progname);
+
return -1;
}
}
if (ptl_parse_nid (&nid, buf) != 0) {
- fprintf (stderr, "mount: can't parse NID %s\n", buf);
+ fprintf (stderr, "%s: can't parse NID %s\n", progname, buf);
return (-1);
}
if (lmd->lmd_nal == SOCKNAL || lmd->lmd_nal == TCPNAL) {
if (lmd->lmd_server_nid == PTL_NID_ANY) {
if (ptl_parse_nid (&nid, hostname) != 0) {
- fprintf (stderr, "mount: can't parse NID %s\n",
- hostname);
+ fprintf (stderr, "%s: can't parse NID %s\n",
+ progname, hostname);
return (-1);
}
lmd->lmd_server_nid = nid;
}
if (ptl_parse_ipaddr(&lmd->lmd_server_ipaddr, hostname) != 0) {
- fprintf (stderr, "mount: can't parse host %s\n",
- hostname);
+ fprintf (stderr, "%s: can't parse host %s\n",
+ progname, hostname);
return (-1);
}
} else if (lmd->lmd_nal == QSWNAL) {
char buf[64];
rc = sscanf(hostname, "%*[^0-9]%63[0-9]", buf);
if (rc != 1) {
- fprintf (stderr, "mount: can't get elan id from host %s\n",
- hostname);
+ fprintf (stderr, "%s: can't get elan id from host %s\n",
+ progname, hostname);
return -1;
}
if (ptl_parse_nid (&nid, buf) != 0) {
- fprintf (stderr, "mount: can't parse NID %s\n",
- hostname);
+ fprintf (stderr, "%s: can't parse NID %s\n",
+ progname, hostname);
return (-1);
}
lmd->lmd_server_nid = nid;
return -EINVAL;
if (strlen(source) > sizeof(target) + 1) {
- fprintf(stderr, "mount: "
- "exessively long host:/mds/profile argument\n");
+ fprintf(stderr, "%s: "
+ "exessively long host:/mds/profile argument\n",
+ progname);
return -EINVAL;
}
strcpy(target, source);
*s = '\0';
profile = s + 1;
} else {
- fprintf(stderr, "mount: "
+ fprintf(stderr, "%s: "
"directory to mount not in "
- "host:/mds/profile format\n");
+ "host:/mds/profile format\n",
+ progname);
return(-1);
}
} else {
- fprintf(stderr, "mount: "
- "directory to mount not in host:/mds/profile format\n");
+ fprintf(stderr, "%s: "
+ "directory to mount not in host:/mds/profile format\n",
+ progname);
return(-1);
}
if (verbose)
if (rc)
return rc;
if (strlen(mds) > sizeof(lmd->lmd_mds) + 1) {
- fprintf(stderr, "mount: mds name too long\n");
+ fprintf(stderr, "%s: mds name too long\n", progname);
return(-1);
}
strcpy(lmd->lmd_mds, mds);
if (strlen(profile) > sizeof(lmd->lmd_profile) + 1) {
- fprintf(stderr, "mount: profile name too long\n");
+ fprintf(stderr, "%s: profile name too long\n", progname);
return(-1);
}
strcpy(lmd->lmd_profile, profile);
int rc;
+ progname = strrchr(argv[0], '/');
+ progname = progname ? progname + 1 : argv[0];
+
while ((opt = getopt(argc, argv, "vno:")) != EOF) {
switch (opt) {
case 'v':
}
if (argc < i) {
- printf("Too few args!\n");
- printf("Usage: %s <source> <target> [-v] [-n] [-o ...]\n", argv[0]);
+ fprintf(stderr,
+ "%s: too few arguments\n"
+ "Usage: %s <source> <target> [-v] [-n] [-o ...]\n",
+ progname, progname);
exit(1);
}
}
if (debug) {
- printf("mount: debug mode, not mounting\n");
+ printf("%s: debug mode, not mounting\n", progname);
exit(0);
}