aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-03-24 15:02:04 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:01 -0400
commita9218f6b00ada101c9772ee9c44af04fa5125d2a (patch)
tree2d4896c8cbbcdf0544576a4af48889501345360a /fs/btrfs/super.c
parent7d1660d411a24f9b5a2f38e41c9896d7151c934f (diff)
Add /dev/btrfs-control for device scanning ioctls
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 4423a91206a1..67ed216df475 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -36,6 +36,7 @@
36#include <linux/parser.h> 36#include <linux/parser.h>
37#include <linux/ctype.h> 37#include <linux/ctype.h>
38#include <linux/namei.h> 38#include <linux/namei.h>
39#include <linux/miscdevice.h>
39#include "ctree.h" 40#include "ctree.h"
40#include "disk-io.h" 41#include "disk-io.h"
41#include "transaction.h" 42#include "transaction.h"
@@ -444,6 +445,13 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
444 return 0; 445 return 0;
445} 446}
446 447
448static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
449 unsigned long arg)
450{
451 printk("btrfs control ioctl %d\n", cmd);
452 return 0;
453}
454
447static struct file_system_type btrfs_fs_type = { 455static struct file_system_type btrfs_fs_type = {
448 .owner = THIS_MODULE, 456 .owner = THIS_MODULE,
449 .name = "btrfs", 457 .name = "btrfs",
@@ -451,6 +459,7 @@ static struct file_system_type btrfs_fs_type = {
451 .kill_sb = kill_block_super, 459 .kill_sb = kill_block_super,
452 .fs_flags = FS_REQUIRES_DEV, 460 .fs_flags = FS_REQUIRES_DEV,
453}; 461};
462
454static void btrfs_write_super_lockfs(struct super_block *sb) 463static void btrfs_write_super_lockfs(struct super_block *sb)
455{ 464{
456 struct btrfs_root *root = btrfs_sb(sb); 465 struct btrfs_root *root = btrfs_sb(sb);
@@ -482,6 +491,30 @@ static struct super_operations btrfs_super_ops = {
482 .write_super_lockfs = btrfs_write_super_lockfs, 491 .write_super_lockfs = btrfs_write_super_lockfs,
483 .unlockfs = btrfs_unlockfs, 492 .unlockfs = btrfs_unlockfs,
484}; 493};
494
495static const struct file_operations btrfs_ctl_fops = {
496 .unlocked_ioctl = btrfs_control_ioctl,
497 .compat_ioctl = btrfs_control_ioctl,
498 .owner = THIS_MODULE,
499};
500
501static struct miscdevice btrfs_misc = {
502 .minor = MISC_DYNAMIC_MINOR,
503 .name = "btrfs-control",
504 .fops = &btrfs_ctl_fops
505};
506
507static int btrfs_interface_init(void)
508{
509 return misc_register(&btrfs_misc);
510}
511
512void btrfs_interface_exit(void)
513{
514 if (misc_deregister(&btrfs_misc) < 0)
515 printk("misc_deregister failed for control device");
516}
517
485static int __init init_btrfs_fs(void) 518static int __init init_btrfs_fs(void)
486{ 519{
487 int err; 520 int err;
@@ -503,11 +536,16 @@ static int __init init_btrfs_fs(void)
503 if (err) 536 if (err)
504 goto free_extent_io; 537 goto free_extent_io;
505 538
506 err = register_filesystem(&btrfs_fs_type); 539 err = btrfs_interface_init();
507 if (err) 540 if (err)
508 goto free_extent_map; 541 goto free_extent_map;
542 err = register_filesystem(&btrfs_fs_type);
543 if (err)
544 goto unregister_ioctl;
509 return 0; 545 return 0;
510 546
547unregister_ioctl:
548 btrfs_interface_exit();
511free_extent_map: 549free_extent_map:
512 extent_map_exit(); 550 extent_map_exit();
513free_extent_io: 551free_extent_io:
@@ -526,6 +564,7 @@ static void __exit exit_btrfs_fs(void)
526 btrfs_destroy_cachep(); 564 btrfs_destroy_cachep();
527 extent_map_exit(); 565 extent_map_exit();
528 extent_io_exit(); 566 extent_io_exit();
567 btrfs_interface_exit();
529 unregister_filesystem(&btrfs_fs_type); 568 unregister_filesystem(&btrfs_fs_type);
530 btrfs_exit_sysfs(); 569 btrfs_exit_sysfs();
531} 570}