Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133449
b: refs/heads/master
c: 425cb02
h: refs/heads/master
i:
  133447: d4f72db
v: v3
  • Loading branch information
Alex Chiang authored and Greg Kroah-Hartman committed Mar 24, 2009
1 parent 2d9b755 commit 17e9366
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f48f3febb2cbfd0f2ecee7690835ba745c1034a4
refs/heads/master: 425cb02912d1095febfeaf8d379af7b2ac9e4a89
32 changes: 30 additions & 2 deletions trunk/fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,26 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
return 0;
}

/**
* sysfs_pathname - return full path to sysfs dirent
* @sd: sysfs_dirent whose path we want
* @path: caller allocated buffer
*
* Gives the name "/" to the sysfs_root entry; any path returned
* is relative to wherever sysfs is mounted.
*
* XXX: does no error checking on @path size
*/
static char *sysfs_pathname(struct sysfs_dirent *sd, char *path)
{
if (sd->s_parent) {
sysfs_pathname(sd->s_parent, path);
strcat(path, "/");
}
strcat(path, sd->s_name);
return path;
}

/**
* sysfs_add_one - add sysfs_dirent to parent
* @acxt: addrm context to use
Expand All @@ -458,8 +478,16 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
int ret;

ret = __sysfs_add_one(acxt, sd);
WARN(ret == -EEXIST, KERN_WARNING "sysfs: duplicate filename '%s' "
"can not be created\n", sd->s_name);
if (ret == -EEXIST) {
char *path = kzalloc(PATH_MAX, GFP_KERNEL);
WARN(1, KERN_WARNING
"sysfs: cannot create duplicate filename '%s'\n",
(path == NULL) ? sd->s_name :
strcat(strcat(sysfs_pathname(acxt->parent_sd, path), "/"),
sd->s_name));
kfree(path);
}

return ret;
}

Expand Down

0 comments on commit 17e9366

Please sign in to comment.