Commit 55394bb9 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Fixed CASTOR-4830 : Several minor defects in documenting nsenter/nsmodifyclass.

In particular all unused parameters of the fileclass are no more appearing on the command line tools and the default number of copies is 1
parent bccd7fd8
......@@ -21,35 +21,14 @@ void usage(int status, char *name) {
if (status != 0) {
fprintf (stderr, "Try `%s --help` for more information.\n", name);
} else {
printf ("Usage: %s <--name=CLASSNAME> [OPTION]... \n", name);
printf ("Modify an existing file class.\n\n");
printf (" --gid=CLASSGID the class is restricted to this group gid\n");
printf (" --group=CLASSGRP the class is restricted to this group name\n");
printf (" --id=CLASSID the class number of the class to be modified\n");
printf (" --maxdrives=NUM specifies the number of drives which can be used\n");
printf (" in parallel for a migration\n");
printf (" --maxfilesize=NUM specifies the maximum file size\n");
printf (" --maxsegsize=NUM specifies the maximum segment size\n");
printf (" --migr_interval=NUM a new migration will be started if at least NUM\n");
printf (" seconds have\n");
printf (" elapsed since the last migration\n");
printf (" --minfilesize=NUM specifies the minimum file size\n");
printf (" --mintime=NUM a file will not be migrated unless at least NUM\n");
printf (" seconds have\n");
printf (" elapsed since the last update\n");
printf (" --name=CLASSNAME the name of the class to be modified\n");
printf ("Usage: %s <--name=CLASSNAME> <--id=CLASSID> [OPTION]... \n", name);
printf ("Enter a new file class.\n\n");
printf (" --gid=CLASSGID class group gid\n");
printf (" --group=CLASSGRP class group name\n");
printf (" --id=CLASSID the class id\n");
printf (" --nbcopies=NUM specifies the number of copies for a file\n");
printf (" --retenp_on_disk=NUM specifies the maximum retention period (in seconds)\n");
printf (" for a file on disk. The retention period can also be\n");
printf (" set to AS_LONG_AS_POSSIBLE or INFINITE_LIFETIME. If\n");
printf (" zero, the file is purged immediately after migration.\n");
printf (" Default is AS_LONG_AS_POSSIBLE, i.e. purged when\n");
printf (" disk space is needed\n");
printf (" --tppools=POOL1:POOL2... Specifies the tape pools to be used for migration.\n");
printf (" The number of tape pools must be at least as big as\n");
printf (" the number of copies.\n");
printf (" --uid=CLASSUID the class is restricted to this user uid\n");
printf (" --user=CLASSUSER the class is restricted to this user name\n");
printf (" --uid=CLASSUID class user uid\n");
printf (" --user=CLASSUSER class user name\n");
printf (" -h, --host=HOSTNAME specify the name server hostname\n");
printf (" --help display this help and exit\n\n");
printf ("Report bugs to <castor.support@cern.ch>.\n");
......@@ -67,14 +46,11 @@ int main(int argc,
int errflg = 0;
int hflg = 0;
struct group *gr;
int nbtppools;
char *p = NULL;
struct passwd *pwd;
char *q;
char *server = NULL;
memset (&Cns_fileclass, 0, sizeof(struct Cns_fileclass));
Cns_fileclass.retenp_on_disk = AS_LONG_AS_POSSIBLE;
Cns_fileclass.nbcopies = 1;
Coptions_t longopts[] = {
{ "gid", REQUIRED_ARGUMENT, NULL, OPT_CLASS_GID },
......@@ -83,16 +59,7 @@ int main(int argc,
{ "name", REQUIRED_ARGUMENT, NULL, OPT_CLASS_NAME },
{ "uid", REQUIRED_ARGUMENT, NULL, OPT_CLASS_UID },
{ "user", REQUIRED_ARGUMENT, NULL, OPT_CLASS_USER },
{ "flags", REQUIRED_ARGUMENT, NULL, OPT_FLAGS },
{ "maxdrives", REQUIRED_ARGUMENT, NULL, OPT_MAX_DRV },
{ "maxfilesize", REQUIRED_ARGUMENT, NULL, OPT_MAX_FSZ },
{ "maxsegsize", REQUIRED_ARGUMENT, NULL, OPT_MAX_SSZ },
{ "migr_interval", REQUIRED_ARGUMENT, NULL, OPT_MIGR_INTV },
{ "minfilesize", REQUIRED_ARGUMENT, NULL, OPT_MIN_FSZ },
{ "mintime", REQUIRED_ARGUMENT, NULL, OPT_MIN_TIME },
{ "nbcopies", REQUIRED_ARGUMENT, NULL, OPT_NBCOPIES },
{ "retenp_on_disk", REQUIRED_ARGUMENT, NULL, OPT_RETENP_DISK },
{ "tppools", REQUIRED_ARGUMENT, NULL, OPT_TPPOOLS },
{ "host", REQUIRED_ARGUMENT, NULL, 'h' },
{ "help", NO_ARGUMENT, &hflg, 1 },
{ NULL, 0, NULL, 0 }
......@@ -150,62 +117,6 @@ int main(int argc,
} else
Cns_fileclass.uid = pwd->pw_uid;
break;
case OPT_FLAGS:
if ((Cns_fileclass.flags = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid flags %s\n", Coptarg);
errflg++;
}
break;
case OPT_MAX_DRV:
if ((Cns_fileclass.maxdrives = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid maxdrives %s\n", Coptarg);
errflg++;
}
break;
case OPT_MAX_FSZ:
if ((Cns_fileclass.max_filesize = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid maxfilesize %s\n", Coptarg);
errflg++;
}
break;
case OPT_MAX_SSZ:
if ((Cns_fileclass.max_segsize = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid maxsegsize %s\n", Coptarg);
errflg++;
}
break;
case OPT_MIGR_INTV:
if ((Cns_fileclass.migr_time_interval = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid migr_interval %s\n", Coptarg);
errflg++;
}
break;
case OPT_MIN_FSZ:
if ((Cns_fileclass.min_filesize = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid minfilesize %s\n", Coptarg);
errflg++;
}
break;
case OPT_MIN_TIME:
if ((Cns_fileclass.mintime_beforemigr = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid mintime %s\n", Coptarg);
errflg++;
}
break;
case OPT_NBCOPIES:
if ((Cns_fileclass.nbcopies = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
......@@ -214,46 +125,6 @@ int main(int argc,
errflg++;
}
break;
case OPT_RETENP_DISK:
if (strcmp (Coptarg, "AS_LONG_AS_POSSIBLE") == 0)
Cns_fileclass.retenp_on_disk = AS_LONG_AS_POSSIBLE;
else if (strcmp (Coptarg, "INFINITE_LIFETIME") == 0)
Cns_fileclass.retenp_on_disk = INFINITE_LIFETIME;
else if ((Cns_fileclass.retenp_on_disk =
strtol (Coptarg, &dp, 10)) < 0 || *dp != '\0') {
fprintf (stderr,
"invalid retenp_on_disk %s\n", Coptarg);
errflg++;
}
break;
case OPT_TPPOOLS:
nbtppools = 0;
p = strtok (Coptarg, ":");
while (p) {
if (strlen (p) > CA_MAXPOOLNAMELEN) {
fprintf (stderr,
"invalid tppools %s\n", Coptarg);
errflg++;
} else
nbtppools++;
if ((p = strtok (NULL, ":"))) *(p - 1) = ':';
}
if (errflg) break;
Cns_fileclass.nbtppools = nbtppools;
if ((q = calloc (nbtppools, CA_MAXPOOLNAMELEN+1)) == NULL) {
fprintf (stderr, "nsenterclass %s: %s\n",
Cns_fileclass.name, sstrerror(ENOMEM));
errflg++;
break;
}
Cns_fileclass.tppools = q;
p = strtok (Coptarg, ":");
while (p) {
strcpy (q, p);
q += (CA_MAXPOOLNAMELEN+1);
p = strtok (NULL, ":");
}
break;
case 'h':
server = Coptarg;
setenv(CNS_HOST_ENV, server, 1);
......
......@@ -18,49 +18,18 @@ This command requires ADMIN privileges in the Cupv database.
specify the name server hostname. This can also be set through the
CNS_HOST environment variable.
.TP
.BI --flags=FLAGS
.TP
.BI --gid=CLASSGID
The class is restricted to this group gid.
.TP
.BI --id=CLASSID
The class number must be strictly positive.
.TP
.BI --maxdrives=NUM
Specifies the number of drives which can be used in parallel for a migration.
.TP
.BI --maxfilesize=NUM
Specifies the maximum file size. There is no limit by default.
.TP
.BI --maxsegsize=NUM
Specifies the maximum segment size. There is no limit by default.
.TP
.BI --migr_interval=NUM
A new migration will be started if at least NUM seconds have elapsed since the last migration.
.TP
.BI --minfilesize=NUM
Specifies the minimum file size. The default value is 0.
.TP
.BI --mintime=NUM
A file will not be migrated unless at least NUM seconds have elapsed since the last update.
.TP
.BI --name=CLASSNAME
The class name must be at most CA_MAXCLASNAMELEN characters long.
.TP
.BI --nbcopies=NUM
Specifies the number of copies for a file. Each copy is written to a different
tape pool.
.TP
.BI --retenp_on_disk=NUM
Specifies the maximum retention period (in seconds) for a file on disk.
The retention period can also be set to AS_LONG_AS_POSSIBLE or INFINITE_LIFETIME.
If zero, the file is purged immediately after migration.
Default is AS_LONG_AS_POSSIBLE, i.e. purged when disk space is needed.
.TP
.BI --tppools=POOL1:POOL2...
Specifies the tape pools to be used for migration. The number of tape pools
must be at least as big as the number of copies.
Pool names must be at most CA_MAXPOOLNAMELEN characters long.
tape pool. Default is 1.
.TP
.BI --uid=CLASSUID
The class is restricted to this user uid.
......@@ -73,7 +42,7 @@ Display this help and exit
.SH EXAMPLES
.nf
.ft CW
nsenterclass --id 2 --name user --maxd 2 --migr 60 --nbco 1 --tppools default
nsenterclass --id 2 --name
.ft
.fi
.SH EXIT STATUS
......
......@@ -133,10 +133,7 @@ int main(int argc,char **argv)
int listentry(struct Cns_fileclass *Cns_fileclass)
{
struct group *gr;
int i;
char *p;
struct passwd *pw;
char retenpstr[20];
static gid_t sav_gid = -1;
static char sav_gidstr[7];
static uid_t sav_uid = -1;
......@@ -160,40 +157,16 @@ int listentry(struct Cns_fileclass *Cns_fileclass)
else
sprintf (sav_gidstr, "%-6u", sav_gid);
}
if (Cns_fileclass->retenp_on_disk == AS_LONG_AS_POSSIBLE)
strcpy (retenpstr, "AS_LONG_AS_POSSIBLE");
else if (Cns_fileclass->retenp_on_disk == INFINITE_LIFETIME)
strcpy (retenpstr, "INFINITE_LIFETIME");
else
sprintf (retenpstr, "%d", Cns_fileclass->retenp_on_disk);
p = Cns_fileclass->tppools;
if (nohdr) {
printf ("%d %s %-8.8s %-6.6s 0x%x %d %d %d %d %d %d %d %s %s",
printf ("%d %s %-8.8s %-6.6s %d",
Cns_fileclass->classid, Cns_fileclass->name, sav_uidstr, sav_gidstr,
Cns_fileclass->flags, Cns_fileclass->maxdrives,
Cns_fileclass->min_filesize, Cns_fileclass->max_filesize,
Cns_fileclass->max_segsize, Cns_fileclass->migr_time_interval,
Cns_fileclass->mintime_beforemigr, Cns_fileclass->nbcopies,
retenpstr, p);
Cns_fileclass->nbcopies);
} else {
printf ("CLASS_ID %d\n", Cns_fileclass->classid);
printf ("CLASS_NAME %s\n", Cns_fileclass->name);
printf ("CLASS_UID %s\n", sav_uidstr);
printf ("CLASS_GID %s\n", sav_gidstr);
printf ("FLAGS 0x%x\n", Cns_fileclass->flags);
printf ("MAXDRIVES %d\n", Cns_fileclass->maxdrives);
printf ("MIN FILESIZE %d\n", Cns_fileclass->min_filesize);
printf ("MAX FILESIZE %d\n", Cns_fileclass->max_filesize);
printf ("MAX SEGSIZE %d\n", Cns_fileclass->max_segsize);
printf ("MIGR INTERVAL %d\n", Cns_fileclass->migr_time_interval);
printf ("MIN TIME %d\n", Cns_fileclass->mintime_beforemigr);
printf ("NBCOPIES %d\n", Cns_fileclass->nbcopies);
printf ("RETENP_ON_DISK %s\n", retenpstr);
printf ("TAPE POOLS %s", Cns_fileclass->nbtppools ? p : "");
}
for (i = 1; i < Cns_fileclass->nbtppools; i++) {
p += (CA_MAXPOOLNAMELEN+1);
printf (":%s", p);
printf ("NBCOPIES %d", Cns_fileclass->nbcopies);
}
printf ("\n");
return (0);
......
......@@ -38,16 +38,7 @@ CLASS_ID 2
CLASS_NAME user
CLASS_UID -
CLASS_GID -
FLAGS 0x0
MAXDRIVES 2
MIN FILESIZE 0
MAX FILESIZE 0
MAX SEGSIZE 0
MIGR INTERVAL 1800
MIN TIME 0
NBCOPIES 1
RETENP_ON_DISK AS_LONG_AS_POSSIBLE
TAPE POOLS default
nslistclass --id 2 -nohdr
......
......@@ -26,29 +26,9 @@ void usage(int status, char *name) {
printf (" --gid=CLASSGID the class is restricted to this group gid\n");
printf (" --group=CLASSGRP the class is restricted to this group name\n");
printf (" --id=CLASSID the class number of the class\n");
printf (" --maxdrives=NUM specifies the number of drives which can be used\n");
printf (" in parallel for a migration\n");
printf (" --maxfilesize=NUM specifies the maximum file size\n");
printf (" --maxsegsize=NUM specifies the maximum segment size\n");
printf (" --migr_interval=NUM a new migration will be started if at least NUM\n");
printf (" seconds have\n");
printf (" elapsed since the last migration\n");
printf (" --minfilesize=NUM specifies the minimum file size\n");
printf (" --mintime=NUM a file will not be migrated unless at least NUM\n");
printf (" seconds have\n");
printf (" elapsed since the last update\n");
printf (" --name=CLASSNAME the name of the class\n");
printf (" --nbcopies=NUM specifies the number of copies for a file\n");
printf (" --newname=CLASSNAME the new name for this class\n");
printf (" --retenp_on_disk=NUM specifies the maximum retention period (in seconds)\n");
printf (" for a file on disk. The retention period can also be\n");
printf (" set to AS_LONG_AS_POSSIBLE or INFINITE_LIFETIME. If\n");
printf (" zero, the file is purged immediately after migration.\n");
printf (" Default is AS_LONG_AS_POSSIBLE, i.e. purged when\n");
printf (" disk space is needed\n");
printf (" --tppools=POOL1:POOL2... Specifies the tape pools to be used for migration.\n");
printf (" The number of tape pools must be at least as big as\n");
printf (" the number of copies.\n");
printf (" --uid=CLASSUID the class is restricted to this user uid\n");
printf (" --user=CLASSUSER the class is restricted to this user name\n");
printf (" -h, --host=HOSTNAME specify the name server hostname\n");
......@@ -69,10 +49,7 @@ int main(int argc,
int errflg = 0;
int hflg = 0;
struct group *gr;
int nbtppools;
char *p = NULL;
struct passwd *pwd;
char *q;
char *server = NULL;
memset (&Cns_fileclass, 0xFF, sizeof(struct Cns_fileclass));
......@@ -85,17 +62,8 @@ int main(int argc,
{ "name", REQUIRED_ARGUMENT, NULL, OPT_CLASS_NAME },
{ "uid", REQUIRED_ARGUMENT, NULL, OPT_CLASS_UID },
{ "user", REQUIRED_ARGUMENT, NULL, OPT_CLASS_USER },
{ "flags", REQUIRED_ARGUMENT, NULL, OPT_FLAGS },
{ "maxdrives", REQUIRED_ARGUMENT, NULL, OPT_MAX_DRV },
{ "maxfilesize", REQUIRED_ARGUMENT, NULL, OPT_MAX_FSZ },
{ "maxsegsize", REQUIRED_ARGUMENT, NULL, OPT_MAX_SSZ },
{ "migr_interval", REQUIRED_ARGUMENT, NULL, OPT_MIGR_INTV },
{ "minfilesize", REQUIRED_ARGUMENT, NULL, OPT_MIN_FSZ },
{ "mintime", REQUIRED_ARGUMENT, NULL, OPT_MIN_TIME },
{ "nbcopies", REQUIRED_ARGUMENT, NULL, OPT_NBCOPIES },
{ "newname", REQUIRED_ARGUMENT, NULL, OPT_NEW_C_NAME },
{ "retenp_on_disk", REQUIRED_ARGUMENT, NULL, OPT_RETENP_DISK },
{ "tppools", REQUIRED_ARGUMENT, NULL, OPT_TPPOOLS },
{ "host", REQUIRED_ARGUMENT, NULL, 'h' },
{ "help", NO_ARGUMENT, &hflg, 1 },
{ NULL, 0, NULL, 0 }
......@@ -154,62 +122,6 @@ int main(int argc,
} else
Cns_fileclass.uid = pwd->pw_uid;
break;
case OPT_FLAGS:
if ((Cns_fileclass.flags = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid flags %s\n", Coptarg);
errflg++;
}
break;
case OPT_MAX_DRV:
if ((Cns_fileclass.maxdrives = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid maxdrives %s\n", Coptarg);
errflg++;
}
break;
case OPT_MAX_FSZ:
if ((Cns_fileclass.max_filesize = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid maxfilesize %s\n", Coptarg);
errflg++;
}
break;
case OPT_MAX_SSZ:
if ((Cns_fileclass.max_segsize = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid maxsegsize %s\n", Coptarg);
errflg++;
}
break;
case OPT_MIGR_INTV:
if ((Cns_fileclass.migr_time_interval = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid migr_interval %s\n", Coptarg);
errflg++;
}
break;
case OPT_MIN_FSZ:
if ((Cns_fileclass.min_filesize = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid minfilesize %s\n", Coptarg);
errflg++;
}
break;
case OPT_MIN_TIME:
if ((Cns_fileclass.mintime_beforemigr = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
fprintf (stderr,
"invalid mintime %s\n", Coptarg);
errflg++;
}
break;
case OPT_NBCOPIES:
if ((Cns_fileclass.nbcopies = strtol (Coptarg, &dp, 10)) < 0 ||
*dp != '\0') {
......@@ -226,48 +138,6 @@ int main(int argc,
} else
strcpy (Cns_fileclass.name, Coptarg);
break;
case OPT_RETENP_DISK:
if (strcmp (Coptarg, "AS_LONG_AS_POSSIBLE") == 0)
Cns_fileclass.retenp_on_disk = AS_LONG_AS_POSSIBLE;
else if (strcmp (Coptarg, "INFINITE_LIFETIME") == 0)
Cns_fileclass.retenp_on_disk = INFINITE_LIFETIME;
else if ((Cns_fileclass.retenp_on_disk =
strtol (Coptarg, &dp, 10)) < 0 || *dp != '\0') {
fprintf (stderr,
"invalid retenp_on_disk %s\n", Coptarg);
errflg++;
}
break;
case OPT_TPPOOLS:
nbtppools = 0;
p = strtok (Coptarg, ":");
if (p == NULL)
nbtppools++;
while (p) {
if (strlen (p) > CA_MAXPOOLNAMELEN) {
fprintf (stderr,
"invalid tppools %s\n", Coptarg);
errflg++;
} else
nbtppools++;
if ((p = strtok (NULL, ":"))) *(p - 1) = ':';
}
if (errflg) break;
Cns_fileclass.nbtppools = nbtppools;
if ((q = calloc (nbtppools, CA_MAXPOOLNAMELEN+1)) == NULL) {
fprintf (stderr, "nsmodifyclass %s: %s\n",
Cns_fileclass.name, sstrerror(ENOMEM));
errflg++;
break;
}
Cns_fileclass.tppools = q;
p = strtok (Coptarg, ":");
while (p) {
strcpy (q, p);
q += (CA_MAXPOOLNAMELEN+1);
p = strtok (NULL, ":");
}
break;
case 'h':
server = Coptarg;
setenv(CNS_HOST_ENV, server, 1);
......
......@@ -31,24 +31,6 @@ The class is restricted to this group name
.BI --id=CLASSID
The class number of the class to be modified.
.TP
.BI --maxdrives=NUM
Specifies the number of drives which can be used in parallel for a migration.
.TP
.BI --maxfilesize=NUM
Specifies the maximum file size. There is no limit by default.
.TP
.BI --maxsegsize=NUM
Specifies the maximum segment size. There is no limit by default.
.TP
.BI --migr_interval=NUM
A new migration will be started if at least NUM seconds have elapsed since the last migration.
.TP
.BI --minfilesize=NUM
Specifies the minimum file size. The default value is 0.
.TP
.BI --mintime=NUM
A file will not be migrated unless at least NUM seconds have elapsed since the last update.
.TP
.BI --name=CLASSNAME
The name of the class to be modified.
.TP
......@@ -59,17 +41,6 @@ tape pool.
.BI --newname=CLASSNAME
The class name must be at most CA_MAXCLASNAMELEN characters long.
.TP
.BI --retenp_on_disk=NUM
Specifies the maximum retention period (in seconds) for a file on disk.
The retention period can also be set to AS_LONG_AS_POSSIBLE or INFINITE_LIFETIME.
If zero, the file is purged immediately after migration.
Default is AS_LONG_AS_POSSIBLE, i.e. purged when disk space is needed.
.TP
.BI --tppools=POOL1:POOL2...
Specifies the tape pools to be used for migration. The number of tape pools
must be at least as big as the number of copies.
Pool names must be at most CA_MAXPOOLNAMELEN characters long.
.TP
.BI --uid=CLASSUID
The class is restricted to this user uid.
.TP
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment