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.
15 #include <linux/config.h> /* for CONFIG_PROC_FS */
16 #include <linux/module.h>
17 #include <linux/errno.h>
18 #include <linux/kernel.h>
19 #include <linux/major.h>
20 /* #include <linux/kmod.h> for request_module() */
21 #include <linux/sched.h>
23 #include <linux/malloc.h>
24 #include <linux/ioport.h>
25 #include <linux/fcntl.h>
26 #include <linux/delay.h>
27 #include <linux/skbuff.h>
28 #include <linux/proc_fs.h>
29 #include <linux/vmalloc.h>
31 #include <linux/poll.h>
32 #include <linux/init.h>
33 #include <linux/list.h>
35 #include <asm/segment.h>
36 #include <asm/system.h>
38 #include <asm/uaccess.h>
39 #include <linux/miscdevice.h>
41 #include <linux/filter.h>
42 #include <linux/snapfs.h>
43 #include <linux/snapsupport.h>
45 #if 1 /* XXX - enable for debug messages */
46 int snap_print_entry = 1;
47 int snap_debug_level = ~D_INFO;
49 int snap_print_entry = 0;
50 int snap_debug_level = 0;
55 struct snap_control_device snap_dev;
57 extern int snap_ioctl (struct inode * inode, struct file * filp,
58 unsigned int cmd, unsigned long arg);
60 /* called when opening /dev/device */
61 static int snap_psdev_open(struct inode * inode, struct file * file)
68 dev = MINOR(inode->i_rdev);
69 if (dev != SNAP_PSDEV_MINOR)
77 /* called when closing /dev/device */
78 static int snap_psdev_release(struct inode * inode, struct file * file)
85 dev = MINOR(inode->i_rdev);
86 if (dev != SNAP_PSDEV_MINOR)
95 /* XXX need ioctls here to do snap_delete and snap_restore, snap_backup */
98 /* declare character device */
99 static struct file_operations snapcontrol_fops = {
103 NULL, /* presto_psdev_readdir */
105 snap_ioctl, /* ioctl */
106 NULL, /* presto_psdev_mmap */
107 snap_psdev_open, /* open */
109 snap_psdev_release, /* release */
117 #define SNAPFS_MINOR 240
119 static struct miscdevice snapcontrol_dev = {
125 int init_snap_psdev(void)
127 printk(KERN_INFO "SNAP psdev driver v0.01, braam@mountainviewdata.com\n");
129 misc_register( &snapcontrol_dev );
134 void snap_cleanup_psdev(void)
137 misc_deregister(&snapcontrol_dev);
142 MODULE_AUTHOR("Peter J. Braam <braam@cs.cmu.edu>");
143 MODULE_DESCRIPTION("Snapfs file system filters v0.01");
145 extern int init_snapfs(void);
146 extern int cleanup_snapfs(void);
147 extern int init_clonefs(void);
148 extern int init_snap_sysctl(void);
150 int init_module(void)
153 if ( (err = init_snap_psdev()) ) {
154 printk("Error initializing snap_psdev, %d\n", err);
158 if ( (err = init_snapfs()) ) {
159 printk("Error initializing snapfs, %d\n", err);
163 if ( (err = init_snapfs_proc_sys()) ) {
164 printk("Error initializing snapfs proc sys, %d\n", err);
172 void cleanup_module(void)
176 snap_cleanup_psdev();