mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
fs: Get parent dir cell for 'fs getfid -literal'
After we get the fid for the requested path, 'fs getfid' then gets the cell for the path: GetCell(ti->data, cell); But ti->data is the full path requested, whether -literal was given or not. If the given path ends with a broken symlink/mountpoint or nonexistent fid, we've already gotten the fid (if -literal was given) but we'll still exit with an (often confusing) error: $ fs getfid symlink.broken -literal fs: no such cell as 'symlink.broken' In addition, if we use 'fs getfid -literal' to get the fid of a cross-cell mountpoint object, we'll get the wrong cell. We'll report the cell of the mountpoint's target, instead of the cell of the reported fid: $ fs getfid /afs/example.com -literal File /afs/example.com (1.16777244.1) located in cell example.com To fix these, pass 'parent_dir' to GetCell() when -literal is given. To do this, we need to not free parent_dir until later, so reorganize the 'parent_dir' and 'last_component' vars to be freed at the end of the loop, and change the 'continue' code paths to goto the end of the loop instead. With this, the cell is now reported properly for these cases: $ fs getfid symlink.broken -literal File symlink.broken (536871063.22.865) located in cell example.com $ fs getfid /afs/example.com -literal File /afs/example.com (1.16777244.1) located in cell dynroot Change-Id: I8ec297dae84f677d530b6f7c39786f18c2a9c50f Reviewed-on: https://gerrit.openafs.org/15584 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
10e21591ca
commit
cad39264b6
@ -4261,50 +4261,54 @@ GetFidCmd(struct cmd_syndesc *as, void *arock)
|
||||
}
|
||||
for (ti = as->parms[0].items; ti; ti = ti->next) {
|
||||
struct VenusFid vfid;
|
||||
char *parent_dir = NULL;
|
||||
char *last_component = NULL;
|
||||
|
||||
blob.out_size = sizeof(struct VenusFid);
|
||||
blob.out = (char *) &vfid;
|
||||
blob.in_size = 0;
|
||||
|
||||
if (literal) {
|
||||
char *parent_dir = NULL;
|
||||
char *last_component = NULL;
|
||||
|
||||
if (GetLastComponent(ti->data, &parent_dir,
|
||||
&last_component, NULL, literal) != 0) {
|
||||
error = 1;
|
||||
continue;
|
||||
goto next_item;
|
||||
}
|
||||
|
||||
blob.in = last_component;
|
||||
blob.in_size = strlen(last_component) + 1;
|
||||
code = pioctl(parent_dir, VIOC_GETLITERALFID, &blob, 1);
|
||||
|
||||
free(parent_dir);
|
||||
free(last_component);
|
||||
} else {
|
||||
code = pioctl(ti->data, VIOCGETFID, &blob, 1);
|
||||
}
|
||||
if (code) {
|
||||
Die(errno,ti->data);
|
||||
error = 1;
|
||||
continue;
|
||||
goto next_item;
|
||||
}
|
||||
|
||||
code = GetCell(ti->data, cell);
|
||||
if (literal) {
|
||||
code = GetCell(parent_dir, cell);
|
||||
} else {
|
||||
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;
|
||||
goto next_item;
|
||||
}
|
||||
|
||||
printf("File %s (%u.%u.%u) located in cell %s\n",
|
||||
ti->data, vfid.Fid.Volume, vfid.Fid.Vnode, vfid.Fid.Unique,
|
||||
cell);
|
||||
|
||||
next_item:
|
||||
free(parent_dir);
|
||||
free(last_component);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user