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"
32 int snap_print_entry = 1;
33 int snap_debug_level = 0;
35 long snap_kmemory = 0;
37 struct snap_control_device snap_dev;
39 extern int snap_ioctl (struct inode * inode, struct file * filp,
40 unsigned int cmd, unsigned long arg);
42 /* called when opening /dev/device */
43 static int snap_psdev_open(struct inode * inode, struct file * file)
50 dev = MINOR(inode->i_rdev);
51 if (dev != SNAP_PSDEV_MINOR)
57 /* called when closing /dev/device */
58 static int snap_psdev_release(struct inode * inode, struct file * file)
65 dev = MINOR(inode->i_rdev);
66 if (dev != SNAP_PSDEV_MINOR)
72 /* XXX need ioctls here to do snap_delete and snap_restore, snap_backup */
75 /* declare character device */
76 static struct file_operations snapcontrol_fops = {
77 ioctl: snap_ioctl, /* ioctl */
78 open: snap_psdev_open, /* open */
79 release: snap_psdev_release, /* release */
84 #define SNAPFS_MINOR 240
86 static struct miscdevice snapcontrol_dev = {
89 fops: &snapcontrol_fops
92 int init_snap_psdev(void)
94 printk(KERN_INFO "SNAP psdev driver v0.01, braam@clusterfs.com\n");
96 misc_register( &snapcontrol_dev );
101 void snap_cleanup_psdev(void)
104 misc_deregister(&snapcontrol_dev);
108 MODULE_AUTHOR("Peter J. Braam <braam@cs.cmu.edu>");
109 MODULE_DESCRIPTION("Snapfs file system filters v0.01");
111 extern int init_snapfs(void);
112 extern int cleanup_snapfs(void);
113 extern int init_clonefs(void);
114 extern int init_snap_sysctl(void);
116 static int __init snapfs_init(void)
119 if ( (err = init_snap_psdev()) ) {
120 printk("Error initializing snap_psdev, %d\n", err);
124 if ( (err = init_snapfs()) ) {
125 printk("Error initializing snapfs, %d\n", err);
129 if ( (err = init_snapfs_proc_sys()) ) {
130 printk("Error initializing snapfs proc sys, %d\n", err);
137 static void __exit snapfs_cleanup(void)
141 snap_cleanup_psdev();
144 module_init(snapfs_init);
145 module_exit(snapfs_cleanup);