mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
fs: Report errors more consistently from GetCell()
Errors from GetCell() are reported a bit oddly in its three callers: - In WhichCellCmd() (and GetFidCmd() before change Idd4727304061e1ec4eeddd98bd9eaab5de96e2b6), we print an odd "no such cell" error for ENOENT, and a more normal message for all other errors. - In BadName() (and GetFidCmd() after change Idd4727304061e1ec4eeddd98bd9eaab5de96e2b6), we don't print an error at all, sometimes making it not obvious that an error has occurred. (BadName() is called from 'fs cleanacl'.) The ENOENT message can be confusing to users, since ENOENT is the error code we get if the given path doesn't exist. This is easy to see with 'fs whichcell': $ fs whichcell notexist fs: no such cell as 'notexist' The VIOC_FILE_CELL_NAME pioctl also never returns ENOENT itself, so this only happens if the given file doesn't exist. This behavior goes back to OpenAFS 1.0. To improve this, change GetCell() to report errors itself. So now errors are reported from it consistently, and are printed for all callers. For example: $ fs whichcell notexist fs: Failed to get cell for 'notexist' fs: File 'notexist' doesn't exist The message is a little redundant, but this lets us use the existing error reporting from Die() while still providing context for what is failing, since it may not be obvious for 'fs cleanacl' or 'fs getfid'. Change-Id: Ib4a84288a9c2d94b2b0d3c4c360fc5c014e98b30 Reviewed-on: https://gerrit.openafs.org/15586 Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
parent
93036c852d
commit
4baeaf1d9f
@ -1016,7 +1016,12 @@ GetCell(char *fname, char *cellname)
|
||||
blob.out = cellname;
|
||||
|
||||
code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
|
||||
return code ? errno : 0;
|
||||
if (code != 0) {
|
||||
code = errno;
|
||||
fprintf(stderr, "%s: Failed to get cell for '%s'\n", pn, fname);
|
||||
Die(code, fname);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/* Check if a username is valid: If it contains only digits (or a
|
||||
@ -2675,10 +2680,6 @@ WhichCellCmd(struct cmd_syndesc *as, void *arock)
|
||||
for (ti = as->parms[0].items; ti; ti = ti->next) {
|
||||
code = GetCell(ti->data, cell);
|
||||
if (code) {
|
||||
if (errno == ENOENT)
|
||||
fprintf(stderr, "%s: no such cell as '%s'\n", pn, ti->data);
|
||||
else
|
||||
Die(errno, ti->data);
|
||||
error = 1;
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user