diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-09 20:28:22 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:35:19 -0400 |
| commit | c3b1a350846a11dd1054cb7832e098aa37025deb (patch) | |
| tree | 0915cd01d07b4b41c2133e307d7b74cb34a94a43 /fs/debugfs | |
| parent | ee3efa91e240f513898050ef305a49a653c8ed90 (diff) | |
debugfs: make sure that debugfs_create_file() gets used only for regulars
It, debugfs_create_dir() and debugfs_create_link() use the common helper
now.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/debugfs')
| -rw-r--r-- | fs/debugfs/inode.c | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index b80bc846a15a..d423b966bc79 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
| @@ -335,6 +335,30 @@ static int debugfs_create_by_name(const char *name, umode_t mode, | |||
| 335 | return error; | 335 | return error; |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | struct dentry *__create_file(const char *name, umode_t mode, | ||
| 339 | struct dentry *parent, void *data, | ||
| 340 | const struct file_operations *fops) | ||
| 341 | { | ||
| 342 | struct dentry *dentry = NULL; | ||
| 343 | int error; | ||
| 344 | |||
| 345 | pr_debug("debugfs: creating file '%s'\n",name); | ||
| 346 | |||
| 347 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, | ||
| 348 | &debugfs_mount_count); | ||
| 349 | if (error) | ||
| 350 | goto exit; | ||
| 351 | |||
| 352 | error = debugfs_create_by_name(name, mode, parent, &dentry, | ||
| 353 | data, fops); | ||
| 354 | if (error) { | ||
| 355 | dentry = NULL; | ||
| 356 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); | ||
| 357 | } | ||
| 358 | exit: | ||
| 359 | return dentry; | ||
| 360 | } | ||
| 361 | |||
| 338 | /** | 362 | /** |
| 339 | * debugfs_create_file - create a file in the debugfs filesystem | 363 | * debugfs_create_file - create a file in the debugfs filesystem |
| 340 | * @name: a pointer to a string containing the name of the file to create. | 364 | * @name: a pointer to a string containing the name of the file to create. |
| @@ -365,25 +389,15 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode, | |||
| 365 | struct dentry *parent, void *data, | 389 | struct dentry *parent, void *data, |
| 366 | const struct file_operations *fops) | 390 | const struct file_operations *fops) |
| 367 | { | 391 | { |
| 368 | struct dentry *dentry = NULL; | 392 | switch (mode & S_IFMT) { |
| 369 | int error; | 393 | case S_IFREG: |
| 370 | 394 | case 0: | |
| 371 | pr_debug("debugfs: creating file '%s'\n",name); | 395 | break; |
| 372 | 396 | default: | |
| 373 | error = simple_pin_fs(&debug_fs_type, &debugfs_mount, | 397 | BUG(); |
| 374 | &debugfs_mount_count); | ||
| 375 | if (error) | ||
| 376 | goto exit; | ||
| 377 | |||
| 378 | error = debugfs_create_by_name(name, mode, parent, &dentry, | ||
| 379 | data, fops); | ||
| 380 | if (error) { | ||
| 381 | dentry = NULL; | ||
| 382 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); | ||
| 383 | goto exit; | ||
| 384 | } | 398 | } |
| 385 | exit: | 399 | |
| 386 | return dentry; | 400 | return __create_file(name, mode, parent, data, fops); |
| 387 | } | 401 | } |
| 388 | EXPORT_SYMBOL_GPL(debugfs_create_file); | 402 | EXPORT_SYMBOL_GPL(debugfs_create_file); |
| 389 | 403 | ||
| @@ -407,8 +421,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_file); | |||
| 407 | */ | 421 | */ |
| 408 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) | 422 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) |
| 409 | { | 423 | { |
| 410 | return debugfs_create_file(name, | 424 | return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, |
| 411 | S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | ||
| 412 | parent, NULL, NULL); | 425 | parent, NULL, NULL); |
| 413 | } | 426 | } |
| 414 | EXPORT_SYMBOL_GPL(debugfs_create_dir); | 427 | EXPORT_SYMBOL_GPL(debugfs_create_dir); |
| @@ -446,8 +459,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, | |||
| 446 | if (!link) | 459 | if (!link) |
| 447 | return NULL; | 460 | return NULL; |
| 448 | 461 | ||
| 449 | result = debugfs_create_file(name, S_IFLNK | S_IRWXUGO, parent, link, | 462 | result = __create_file(name, S_IFLNK | S_IRWXUGO, parent, link, NULL); |
| 450 | NULL); | ||
| 451 | if (!result) | 463 | if (!result) |
| 452 | kfree(link); | 464 | kfree(link); |
| 453 | return result; | 465 | return result; |
