Revision 936532a4
b/hw/9pfs/virtio-9p.c | ||
---|---|---|
423 | 423 |
v9fs_string_sprintf(lhs, "%s", rhs->data); |
424 | 424 |
} |
425 | 425 |
|
426 |
/* |
|
427 |
* Return TRUE if s1 is an ancestor of s2. |
|
428 |
* |
|
429 |
* E.g. "a/b" is an ancestor of "a/b/c" but not of "a/bc/d". |
|
430 |
* As a special case, We treat s1 as ancestor of s2 if they are same! |
|
431 |
*/ |
|
432 |
static int v9fs_path_is_ancestor(V9fsString *s1, V9fsString *s2) |
|
433 |
{ |
|
434 |
if (!strncmp(s1->data, s2->data, s1->size)) { |
|
435 |
if (s2->data[s1->size] == '\0' || s2->data[s1->size] == '/') { |
|
436 |
return 1; |
|
437 |
} |
|
438 |
} |
|
439 |
return 0; |
|
440 |
} |
|
441 |
|
|
426 | 442 |
static size_t v9fs_string_size(V9fsString *str) |
427 | 443 |
{ |
428 | 444 |
return str->size; |
... | ... | |
2805 | 2821 |
for (fidp = s->fid_list; fidp; fidp = fidp->next) { |
2806 | 2822 |
if (vs->fidp == fidp) { |
2807 | 2823 |
/* |
2808 |
* we replace name of this fid towards the end |
|
2809 |
* so that our below strcmp will work |
|
2824 |
* we replace name of this fid towards the end so |
|
2825 |
* that our below v9fs_path_is_ancestor check will |
|
2826 |
* work |
|
2810 | 2827 |
*/ |
2811 | 2828 |
continue; |
2812 | 2829 |
} |
2813 |
if (!strncmp(vs->fidp->path.data, fidp->path.data, |
|
2814 |
strlen(vs->fidp->path.data))) { |
|
2830 |
if (v9fs_path_is_ancestor(&vs->fidp->path, &fidp->path)) { |
|
2815 | 2831 |
/* replace the name */ |
2816 | 2832 |
v9fs_fix_path(&fidp->path, &vs->name, |
2817 | 2833 |
strlen(vs->fidp->path.data)); |
Also available in: Unified diff