tp = strrchr(tspace, '/');
if (tp == (char *)tspace)
tp++;
- else if (tp == (char *)NULL) {
+ else if (tp == NULL) {
tp = (char *)tspace;
*(tp++) = '.';
}
if (*aitemp)
return; /* already has value */
/* otherwise, allocate an item representing "." */
- ti = (struct cmd_item *)malloc(sizeof(struct cmd_item));
+ ti = malloc(sizeof(struct cmd_item));
assert(ti);
ti->next = (struct cmd_item *)0;
- ti->data = (char *)malloc(2);
+ ti->data = malloc(2);
assert(ti->data);
strcpy(ti->data, ".");
*aitemp = ti;
return; /* can't reduce non-existing rights */
/* Otherwise we make a new item and plug in the new data. */
- tlist = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+ tlist = malloc(sizeof(struct AclEntry));
assert(tlist);
strcpy(tlist->name, aname);
tlist->rights = arights;
struct Acl *tp;
int junk;
- tp = (struct Acl *)malloc(sizeof(struct Acl));
+ tp = malloc(sizeof(struct Acl));
assert(tp);
tp->nplus = tp->nminus = 0;
tp->pluslist = tp->minuslist = 0;
tp->dfs = 0;
- sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
+ sscanf(astr, "%d dfs:%d %1024s", &junk, &tp->dfs, tp->cell);
return tp;
}
struct AclEntry *first, *last, *tl;
struct Acl *ta;
- ta = (struct Acl *)malloc(sizeof(struct Acl));
+ ta = malloc(sizeof(struct Acl));
assert(ta);
ta->dfs = 0;
- sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
+ sscanf(astr, "%d dfs:%d %1024s", &ta->nplus, &ta->dfs, ta->cell);
astr = SkipLine(astr);
sscanf(astr, "%d", &ta->nminus);
astr = SkipLine(astr);
last = 0;
first = 0;
for (i = 0; i < nplus; i++) {
- sscanf(astr, "%100s %d", tname, &trights);
+ sscanf(astr, "%99s %d", tname, &trights);
astr = SkipLine(astr);
- tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+ tl = malloc(sizeof(struct AclEntry));
assert(tl);
if (!first)
first = tl;
last = 0;
first = 0;
for (i = 0; i < nminus; i++) {
- sscanf(astr, "%100s %d", tname, &trights);
+ sscanf(astr, "%99s %d", tname, &trights);
astr = SkipLine(astr);
- tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+ tl = malloc(sizeof(struct AclEntry));
assert(tl);
if (!first)
first = tl;
return error;
}
+static int
+FlushAllVolumesCmd(struct cmd_syndesc *as, void *arock)
+{
+ afs_int32 code;
+ struct ViceIoctl blob;
+ int error = 0;
+
+ blob.in_size = 0;
+ blob.out_size = AFS_PIOCTL_MAXSIZE;
+ blob.out = space;
+
+ code = pioctl(NULL, VIOC_FLUSHALL, &blob, 0);
+ if (code) {
+ fprintf(stderr, "Error flushing all volumes\n");
+ error = 1;
+ }
+ return error;
+}
+
/*
* The Windows version of UuidCmd displays the UUID.
* When the UNIX version is updated to do the same
GetLastComponent(const char *data, char **outdir, char **outbase,
int *thru_symlink)
{
- char orig_name[1024]; /*Original name, may be modified */
- char true_name[1024]; /*``True'' dirname (e.g., symlink target) */
+ char orig_name[MAXPATHLEN]; /*Original name, may be modified */
+ char true_name[MAXPATHLEN]; /*``True'' dirname (e.g., symlink target) */
char *lastSlash;
struct stat statbuff; /*Buffer for status info */
int link_chars_read; /*Num chars read in readlink() */
if (thru_symlink)
*thru_symlink = 1;
- /* Read name of resolved file */
- link_chars_read = readlink(orig_name, true_name, 1024);
+ /* Read name of resolved file (leave space for NULL!) */
+ link_chars_read = readlink(orig_name, true_name, MAXPATHLEN-1);
if (link_chars_read <= 0) {
fprintf(stderr,
"%s: Can't read target name for '%s' symbolic link!\n",
code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
free(last_component);
- free(parent_dir);
if (code == 0) {
printf("'%s' is a %smount point for volume '%s'\n", ti->data,
}
error = 1;
}
+ free(parent_dir);
}
return error;
}
blob.in_size = 0;
blob.out_size = AFS_PIOCTL_MAXSIZE;
blob.out = space;
- code =
- pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME,
- &blob, 1);
+ code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME,
+ &blob, 1);
+ if (code) {
+ fprintf(stderr,
+ "%s: couldn't get cell name for file's parent\n", pn);
+ return 1;
+ }
}
dir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
"list configured cells");
cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
- ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, NULL,
- "list configured cell aliases");
+ cmd_CreateSyntax("listaliases", ListAliasesCmd, NULL,
+ "list configured cell aliases");
ts = cmd_CreateSyntax("setquota", SetQuotaCmd, NULL, "set volume quota");
cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
ts = cmd_CreateSyntax("whereis", WhereIsCmd, NULL, "list file's location");
cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
- ts = cmd_CreateSyntax("wscell", WSCellCmd, NULL, "list workstation's cell");
+ cmd_CreateSyntax("wscell", WSCellCmd, NULL, "list workstation's cell");
/*
ts = cmd_CreateSyntax("primarycell", PrimaryCellCmd, NULL, "obsolete (listed primary cell)");
"flush all data in volume");
cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+ cmd_CreateSyntax("flushall", FlushAllVolumesCmd, NULL, "flush all data from the cache");
+
ts = cmd_CreateSyntax("sysname", SysNameCmd, NULL,
"get/set sysname (i.e. @sys) value");
cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
"set cache manager encryption flag");
cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
- ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, NULL,
+ cmd_CreateSyntax("getcrypt", GetCryptCmd, NULL,
"get cache manager encryption flag");
ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, NULL,
"%s: You do not have the required rights to do this operation\n",
pn);
break;
+ case ESRCH: /* hack: pioctls stole ESRCH for cell name not available errors. */
+ fprintf(stderr, "%s: Cell name not recognized.\n", pn);
+ break;
default:
if (filename)
fprintf(stderr, "%s:'%s'", pn, filename);
code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
free(last_component);
- free(parent_dir);
if (code != 0) {
if (errno == EINVAL) {
}
error = 1;
}
+ free(parent_dir);
}
return error;
}