Commit af10ec77b43335ab4e473e4087d85979caf02d65

Authored by Eric W. Biederman
Committed by Greg Kroah-Hartman
1 parent 3ff195b011

sysfs: Add support for tagged directories with untagged members.

I had hopped to avoid this but the bonding driver adds a file
to /sys/class/net/  and the easiest way to handle that file is
to make it untagged and to register it only once.

So relax the rules on tagged directories, and make bonding work.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 2 changed files with 5 additions and 9 deletions Side-by-side Diff

... ... @@ -383,12 +383,6 @@
383 383 if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name))
384 384 return -EEXIST;
385 385  
386   - if (sysfs_ns_type(acxt->parent_sd) && !sd->s_ns) {
387   - WARN(1, KERN_WARNING "sysfs: ns required in '%s' for '%s'\n",
388   - acxt->parent_sd->s_name, sd->s_name);
389   - return -EINVAL;
390   - }
391   -
392 386 sd->s_parent = sysfs_get(acxt->parent_sd);
393 387  
394 388 sysfs_link_sibling(sd);
... ... @@ -545,7 +539,7 @@
545 539 struct sysfs_dirent *sd;
546 540  
547 541 for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) {
548   - if (sd->s_ns != ns)
  542 + if (ns && sd->s_ns && (sd->s_ns != ns))
549 543 continue;
550 544 if (!strcmp(sd->s_name, name))
551 545 return sd;
... ... @@ -879,7 +873,7 @@
879 873 while (pos && (ino > pos->s_ino))
880 874 pos = pos->s_sibling;
881 875 }
882   - while (pos && pos->s_ns != ns)
  876 + while (pos && pos->s_ns && pos->s_ns != ns)
883 877 pos = pos->s_sibling;
884 878 return pos;
885 879 }
... ... @@ -890,7 +884,7 @@
890 884 pos = sysfs_dir_pos(ns, parent_sd, ino, pos);
891 885 if (pos)
892 886 pos = pos->s_sibling;
893   - while (pos && pos->s_ns != ns)
  887 + while (pos && pos->s_ns && pos->s_ns != ns)
894 888 pos = pos->s_sibling;
895 889 return pos;
896 890 }
... ... @@ -335,6 +335,8 @@
335 335 sysfs_addrm_start(&acxt, dir_sd);
336 336  
337 337 sd = sysfs_find_dirent(dir_sd, ns, name);
  338 + if (sd && (sd->s_ns != ns))
  339 + sd = NULL;
338 340 if (sd)
339 341 sysfs_remove_one(&acxt, sd);
340 342