]> git.hungrycats.org Git - linux/commitdiff
[PATCH] symlink doesn't support kobj name > 20 charaters (KOBJ_NAME_LEN)
authorLinda Xie <lxiep@us.ibm.com>
Thu, 22 Apr 2004 08:11:12 +0000 (01:11 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Thu, 22 Apr 2004 08:11:12 +0000 (01:11 -0700)
Since symlink.c uses "name" field of a kobj when it calculates the
length,  it gets a wrong value if the kobj's name  has more than 20
charathers.  A correct way to do that is to call kobject_name(kobj)
instead of using kobj->name directly.

fs/sysfs/symlink.c

index 15253445ca5543c032104b0e97569aa754e3b4c5..6216e946e326542fb59dd51a12eacf3319c13a1a 100644 (file)
@@ -42,7 +42,7 @@ static int object_path_length(struct kobject * kobj)
        struct kobject * p = kobj;
        int length = 1;
        do {
-               length += strlen(p->name) + 1;
+               length += strlen(kobject_name(p)) + 1;
                p = p->parent;
        } while (p);
        return length;
@@ -54,11 +54,11 @@ static void fill_object_path(struct kobject * kobj, char * buffer, int length)
 
        --length;
        for (p = kobj; p; p = p->parent) {
-               int cur = strlen(p->name);
+               int cur = strlen(kobject_name(p));
 
                /* back up enough to print this bus id with '/' */
                length -= cur;
-               strncpy(buffer + length,p->name,cur);
+               strncpy(buffer + length,kobject_name(p),cur);
                *(buffer + --length) = '/';
        }
 }