2 * A file system filter driver in the style of InterMezzo
3 * to manage file system snapshots
5 * Author: Peter J. Braam <braam@mountainviewdata.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
16 #define DEBUG_SUBSYSTEM S_SNAP
18 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/slab.h>
22 #include <linux/stat.h>
23 #include <linux/unistd.h>
24 #include <linux/miscdevice.h>
25 #include <linux/jbd.h>
26 #include <linux/ext3_fs.h>
27 #include <linux/snap.h>
29 #include "snapfs_internal.h"
33 long snap_kmemory = 0;
35 struct snap_control_device snap_dev;
37 extern int snap_ioctl (struct inode * inode, struct file * filp,
38 unsigned int cmd, unsigned long arg);
40 /* called when opening /dev/device */
41 static int snap_psdev_open(struct inode * inode, struct file * file)
48 dev = MINOR(inode->i_rdev);
49 if (dev != SNAP_PSDEV_MINOR)
55 /* called when closing /dev/device */
56 static int snap_psdev_release(struct inode * inode, struct file * file)
63 dev = MINOR(inode->i_rdev);
64 if (dev != SNAP_PSDEV_MINOR)
70 /* XXX need ioctls here to do snap_delete and snap_restore, snap_backup */
73 /* declare character device */
74 static struct file_operations snapcontrol_fops = {
75 ioctl: snap_ioctl, /* ioctl */
76 open: snap_psdev_open, /* open */
77 release: snap_psdev_release, /* release */
82 #define SNAPFS_MINOR 240
84 static struct miscdevice snapcontrol_dev = {
87 fops: &snapcontrol_fops
90 int init_snap_psdev(void)
92 printk(KERN_INFO "SNAP psdev driver v0.01, braam@clusterfs.com\n");
94 misc_register( &snapcontrol_dev );
99 void snap_cleanup_psdev(void)
102 misc_deregister(&snapcontrol_dev);
106 MODULE_AUTHOR("Peter J. Braam <braam@cs.cmu.edu>");
107 MODULE_DESCRIPTION("Snapfs file system filters v0.01");
109 extern int init_snapfs(void);
110 extern int cleanup_snapfs(void);
111 extern int init_clonefs(void);
112 extern int init_snap_sysctl(void);
114 static int __init snapfs_init(void)
117 if ( (err = init_snap_psdev()) ) {
118 printk("Error initializing snap_psdev, %d\n", err);
122 if ( (err = init_snapfs()) ) {
123 printk("Error initializing snapfs, %d\n", err);
127 if ( (err = init_snapfs_proc_sys()) ) {
128 printk("Error initializing snapfs proc sys, %d\n", err);
135 static void __exit snapfs_cleanup(void)
139 snap_cleanup_psdev();
142 module_init(snapfs_init);
143 module_exit(snapfs_cleanup);