diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2015-01-25 14:02:31 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-01-25 16:52:31 -0500 |
| commit | ad5abd5ba8c66ea44e24d7b6996e85ab83b412fc (patch) | |
| tree | 02d2140a331819e5f1c128d401e2c34b517a5fc3 /fs | |
| parent | 190afd81e4a5f24d1db6c774ca7f18acde2fca30 (diff) | |
debugfs: kill __create_file()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/debugfs/inode.c | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 100186c2bf0a..18564b08884c 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
| @@ -348,30 +348,6 @@ static struct dentry *end_creating(struct dentry *dentry, int error) | |||
| 348 | return dentry; | 348 | return dentry; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | static struct dentry *__create_file(const char *name, umode_t mode, | ||
| 352 | struct dentry *parent, void *data, | ||
| 353 | const struct file_operations *fops) | ||
| 354 | { | ||
| 355 | struct dentry *dentry = start_creating(name, parent); | ||
| 356 | int error; | ||
| 357 | |||
| 358 | if (IS_ERR(dentry)) | ||
| 359 | return NULL; | ||
| 360 | |||
| 361 | switch (mode & S_IFMT) { | ||
| 362 | case S_IFDIR: | ||
| 363 | error = debugfs_mkdir(dentry, mode); | ||
| 364 | break; | ||
| 365 | case S_IFLNK: | ||
| 366 | error = debugfs_link(dentry, mode, data); | ||
| 367 | break; | ||
| 368 | default: | ||
| 369 | error = debugfs_create(dentry, mode, data, fops); | ||
| 370 | break; | ||
| 371 | } | ||
| 372 | return end_creating(dentry, error); | ||
| 373 | } | ||
| 374 | |||
| 375 | /** | 351 | /** |
| 376 | * debugfs_create_file - create a file in the debugfs filesystem | 352 | * debugfs_create_file - create a file in the debugfs filesystem |
| 377 | * @name: a pointer to a string containing the name of the file to create. | 353 | * @name: a pointer to a string containing the name of the file to create. |
| @@ -402,15 +378,19 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode, | |||
| 402 | struct dentry *parent, void *data, | 378 | struct dentry *parent, void *data, |
| 403 | const struct file_operations *fops) | 379 | const struct file_operations *fops) |
| 404 | { | 380 | { |
| 405 | switch (mode & S_IFMT) { | 381 | struct dentry *dentry; |
| 406 | case S_IFREG: | 382 | int error; |
| 407 | case 0: | 383 | |
| 408 | break; | 384 | if (!(mode & S_IFMT)) |
| 409 | default: | 385 | mode |= S_IFREG; |
| 410 | BUG(); | 386 | BUG_ON(!S_ISREG(mode)); |
| 411 | } | 387 | dentry = start_creating(name, parent); |
| 388 | |||
| 389 | if (IS_ERR(dentry)) | ||
| 390 | return NULL; | ||
| 412 | 391 | ||
| 413 | return __create_file(name, mode, parent, data, fops); | 392 | error = debugfs_create(dentry, mode, data, fops); |
| 393 | return end_creating(dentry, error); | ||
| 414 | } | 394 | } |
| 415 | EXPORT_SYMBOL_GPL(debugfs_create_file); | 395 | EXPORT_SYMBOL_GPL(debugfs_create_file); |
| 416 | 396 | ||
| @@ -434,8 +414,14 @@ EXPORT_SYMBOL_GPL(debugfs_create_file); | |||
| 434 | */ | 414 | */ |
| 435 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) | 415 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) |
| 436 | { | 416 | { |
| 437 | return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | 417 | struct dentry *dentry = start_creating(name, parent); |
| 438 | parent, NULL, NULL); | 418 | int error; |
| 419 | |||
| 420 | if (IS_ERR(dentry)) | ||
| 421 | return NULL; | ||
| 422 | |||
| 423 | error = debugfs_mkdir(dentry, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); | ||
| 424 | return end_creating(dentry, error); | ||
| 439 | } | 425 | } |
| 440 | EXPORT_SYMBOL_GPL(debugfs_create_dir); | 426 | EXPORT_SYMBOL_GPL(debugfs_create_dir); |
| 441 | 427 | ||
| @@ -465,17 +451,26 @@ EXPORT_SYMBOL_GPL(debugfs_create_dir); | |||
| 465 | struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, | 451 | struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, |
| 466 | const char *target) | 452 | const char *target) |
| 467 | { | 453 | { |
| 468 | struct dentry *result; | 454 | struct dentry *dentry; |
| 469 | char *link; | 455 | char *link; |
| 456 | int error; | ||
| 470 | 457 | ||
| 471 | link = kstrdup(target, GFP_KERNEL); | 458 | link = kstrdup(target, GFP_KERNEL); |
| 472 | if (!link) | 459 | if (!link) |
| 473 | return NULL; | 460 | return NULL; |
| 474 | 461 | ||
| 475 | result = __create_file(name, S_IFLNK | S_IRWXUGO, parent, link, NULL); | 462 | dentry = start_creating(name, parent); |
| 476 | if (!result) | 463 | |
| 464 | if (IS_ERR(dentry)) { | ||
| 477 | kfree(link); | 465 | kfree(link); |
| 478 | return result; | 466 | return NULL; |
| 467 | } | ||
| 468 | |||
| 469 | error = debugfs_link(dentry, S_IFLNK | S_IRWXUGO, link); | ||
| 470 | if (error) | ||
| 471 | kfree(link); | ||
| 472 | |||
| 473 | return end_creating(dentry, error); | ||
| 479 | } | 474 | } |
| 480 | EXPORT_SYMBOL_GPL(debugfs_create_symlink); | 475 | EXPORT_SYMBOL_GPL(debugfs_create_symlink); |
| 481 | 476 | ||
