blob: ed97375daae9326ecf2b4864ff9368f1491f642a [file] [log] [blame]
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -08001/*
2 * linux/kernel/power/user.c
3 *
4 * This file provides the user space interface for software suspend/resume.
5 *
6 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
7 *
8 * This file is released under the GPLv2.
9 *
10 */
11
12#include <linux/suspend.h>
13#include <linux/syscalls.h>
Stefan Seyfried35926952006-12-06 20:34:06 -080014#include <linux/reboot.h>
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080015#include <linux/string.h>
16#include <linux/device.h>
17#include <linux/miscdevice.h>
18#include <linux/mm.h>
19#include <linux/swap.h>
20#include <linux/swapops.h>
21#include <linux/pm.h>
22#include <linux/fs.h>
Rafael J. Wysocki97c78012006-10-11 01:20:45 -070023#include <linux/console.h>
Rafael J. Wysockie3920fb2006-09-25 23:32:48 -070024#include <linux/cpu.h>
Nigel Cunningham7dfb7102006-12-06 20:34:23 -080025#include <linux/freezer.h>
Alan Cox52d11022008-06-11 22:07:52 +020026#include <linux/smp_lock.h>
Rafael J. Wysockic7510852009-04-12 20:06:56 +020027#include <scsi/scsi_scan.h>
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080028
29#include <asm/uaccess.h>
30
31#include "power.h"
32
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +020033/*
Rafael J. Wysocki96f73742007-10-26 01:02:15 +020034 * NOTE: The SNAPSHOT_SET_SWAP_FILE and SNAPSHOT_PMOPS ioctls are obsolete and
35 * will be removed in the future. They are only preserved here for
36 * compatibility with existing userland utilities.
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +020037 */
Rafael J. Wysocki96f73742007-10-26 01:02:15 +020038#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +020039#define SNAPSHOT_PMOPS _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int)
40
41#define PMOPS_PREPARE 1
42#define PMOPS_ENTER 2
43#define PMOPS_FINISH 3
44
Rafael J. Wysockicc5d2072007-10-26 01:03:33 +020045/*
46 * NOTE: The following ioctl definitions are wrong and have been replaced with
47 * correct ones. They are only preserved here for compatibility with existing
48 * userland utilities and will be removed in the future.
49 */
50#define SNAPSHOT_ATOMIC_SNAPSHOT _IOW(SNAPSHOT_IOC_MAGIC, 3, void *)
51#define SNAPSHOT_SET_IMAGE_SIZE _IOW(SNAPSHOT_IOC_MAGIC, 6, unsigned long)
52#define SNAPSHOT_AVAIL_SWAP _IOR(SNAPSHOT_IOC_MAGIC, 7, void *)
53#define SNAPSHOT_GET_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 8, void *)
54
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +020055
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080056#define SNAPSHOT_MINOR 231
57
58static struct snapshot_data {
59 struct snapshot_handle handle;
60 int swap;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080061 int mode;
62 char frozen;
63 char ready;
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +020064 char platform_support;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080065} snapshot_state;
66
Rafael J. Wysocki0709db62007-05-06 14:50:45 -070067atomic_t snapshot_device_available = ATOMIC_INIT(1);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080068
69static int snapshot_open(struct inode *inode, struct file *filp)
70{
71 struct snapshot_data *data;
Alan Sternc3e94d82007-11-19 23:38:25 +010072 int error;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080073
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +020074 mutex_lock(&pm_mutex);
75
76 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
77 error = -EBUSY;
78 goto Unlock;
79 }
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080080
Rafael J. Wysocki1525a2a2007-05-06 14:50:44 -070081 if ((filp->f_flags & O_ACCMODE) == O_RDWR) {
Rafael J. Wysocki0709db62007-05-06 14:50:45 -070082 atomic_inc(&snapshot_device_available);
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +020083 error = -ENOSYS;
84 goto Unlock;
Rafael J. Wysocki1525a2a2007-05-06 14:50:44 -070085 }
86 if(create_basic_memory_bitmaps()) {
Rafael J. Wysocki0709db62007-05-06 14:50:45 -070087 atomic_inc(&snapshot_device_available);
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +020088 error = -ENOMEM;
89 goto Unlock;
Rafael J. Wysocki1525a2a2007-05-06 14:50:44 -070090 }
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080091 nonseekable_open(inode, filp);
92 data = &snapshot_state;
93 filp->private_data = data;
94 memset(&data->handle, 0, sizeof(struct snapshot_handle));
95 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) {
Rafael J. Wysockic7510852009-04-12 20:06:56 +020096 /* Hibernating. The image device should be accessible. */
Rafael J. Wysocki915bae92006-12-06 20:34:07 -080097 data->swap = swsusp_resume_device ?
Rafael J. Wysocki7bf23682007-01-05 16:36:28 -080098 swap_type_of(swsusp_resume_device, 0, NULL) : -1;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -080099 data->mode = O_RDONLY;
Alan Sternc3e94d82007-11-19 23:38:25 +0100100 error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
101 if (error)
102 pm_notifier_call_chain(PM_POST_HIBERNATION);
Andrey Borzenkovebae2602009-02-14 02:05:14 +0100103 } else {
Rafael J. Wysockic7510852009-04-12 20:06:56 +0200104 /*
105 * Resuming. We may need to wait for the image device to
106 * appear.
107 */
108 wait_for_device_probe();
109 scsi_complete_async_scans();
110
Andrey Borzenkovebae2602009-02-14 02:05:14 +0100111 data->swap = -1;
112 data->mode = O_WRONLY;
113 error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
114 if (error)
115 pm_notifier_call_chain(PM_POST_RESTORE);
Alan Sternc3e94d82007-11-19 23:38:25 +0100116 }
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200117 if (error)
Alan Sternc3e94d82007-11-19 23:38:25 +0100118 atomic_inc(&snapshot_device_available);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800119 data->frozen = 0;
120 data->ready = 0;
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +0200121 data->platform_support = 0;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800122
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200123 Unlock:
124 mutex_unlock(&pm_mutex);
125
126 return error;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800127}
128
129static int snapshot_release(struct inode *inode, struct file *filp)
130{
131 struct snapshot_data *data;
132
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200133 mutex_lock(&pm_mutex);
134
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800135 swsusp_free();
Rafael J. Wysocki74dfd662007-05-06 14:50:43 -0700136 free_basic_memory_bitmaps();
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800137 data = filp->private_data;
Rafael J. Wysockid1d241c2007-05-06 14:50:47 -0700138 free_all_swap_pages(data->swap);
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200139 if (data->frozen)
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800140 thaw_processes();
Alan Sternc3e94d82007-11-19 23:38:25 +0100141 pm_notifier_call_chain(data->mode == O_WRONLY ?
142 PM_POST_HIBERNATION : PM_POST_RESTORE);
Rafael J. Wysocki0709db62007-05-06 14:50:45 -0700143 atomic_inc(&snapshot_device_available);
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200144
145 mutex_unlock(&pm_mutex);
146
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800147 return 0;
148}
149
150static ssize_t snapshot_read(struct file *filp, char __user *buf,
151 size_t count, loff_t *offp)
152{
153 struct snapshot_data *data;
154 ssize_t res;
155
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200156 mutex_lock(&pm_mutex);
157
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800158 data = filp->private_data;
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200159 if (!data->ready) {
160 res = -ENODATA;
161 goto Unlock;
162 }
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800163 res = snapshot_read_next(&data->handle, count);
164 if (res > 0) {
165 if (copy_to_user(buf, data_of(data->handle), res))
166 res = -EFAULT;
167 else
168 *offp = data->handle.offset;
169 }
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200170
171 Unlock:
172 mutex_unlock(&pm_mutex);
173
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800174 return res;
175}
176
177static ssize_t snapshot_write(struct file *filp, const char __user *buf,
178 size_t count, loff_t *offp)
179{
180 struct snapshot_data *data;
181 ssize_t res;
182
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200183 mutex_lock(&pm_mutex);
184
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800185 data = filp->private_data;
186 res = snapshot_write_next(&data->handle, count);
187 if (res > 0) {
188 if (copy_from_user(data_of(data->handle), buf, res))
189 res = -EFAULT;
190 else
191 *offp = data->handle.offset;
192 }
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200193
194 mutex_unlock(&pm_mutex);
195
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800196 return res;
197}
198
Alan Cox52d11022008-06-11 22:07:52 +0200199static long snapshot_ioctl(struct file *filp, unsigned int cmd,
200 unsigned long arg)
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800201{
202 int error = 0;
203 struct snapshot_data *data;
Rafael J. Wysockiaf508b32007-10-26 00:59:31 +0200204 loff_t size;
Rafael J. Wysocki3aef83e2006-12-06 20:34:10 -0800205 sector_t offset;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800206
207 if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
208 return -ENOTTY;
209 if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR)
210 return -ENOTTY;
211 if (!capable(CAP_SYS_ADMIN))
212 return -EPERM;
213
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200214 if (!mutex_trylock(&pm_mutex))
215 return -EBUSY;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800216
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200217 data = filp->private_data;
Alan Cox52d11022008-06-11 22:07:52 +0200218
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800219 switch (cmd) {
220
221 case SNAPSHOT_FREEZE:
222 if (data->frozen)
223 break;
Rafael J. Wysocki1bfcf132008-10-15 22:01:21 -0700224
Alan Sternc3e94d82007-11-19 23:38:25 +0100225 printk("Syncing filesystems ... ");
226 sys_sync();
227 printk("done.\n");
Rafael J. Wysocki232b1432007-10-18 03:04:44 -0700228
Rafael J. Wysocki1bfcf132008-10-15 22:01:21 -0700229 error = usermodehelper_disable();
Rafael J. Wysockib10d9112007-07-19 01:47:36 -0700230 if (error)
Rafael J. Wysocki1bfcf132008-10-15 22:01:21 -0700231 break;
232
233 error = freeze_processes();
234 if (error) {
Alan Sternc3e94d82007-11-19 23:38:25 +0100235 thaw_processes();
Rafael J. Wysocki1bfcf132008-10-15 22:01:21 -0700236 usermodehelper_enable();
237 }
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800238 if (!error)
239 data->frozen = 1;
240 break;
241
242 case SNAPSHOT_UNFREEZE:
Rafael J. Wysocki2f41ddd2007-06-16 10:16:03 -0700243 if (!data->frozen || data->ready)
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800244 break;
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800245 thaw_processes();
Rafael J. Wysocki1bfcf132008-10-15 22:01:21 -0700246 usermodehelper_enable();
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800247 data->frozen = 0;
248 break;
249
Rafael J. Wysockicc5d2072007-10-26 01:03:33 +0200250 case SNAPSHOT_CREATE_IMAGE:
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800251 case SNAPSHOT_ATOMIC_SNAPSHOT:
252 if (data->mode != O_RDONLY || !data->frozen || data->ready) {
253 error = -EPERM;
254 break;
255 }
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +0200256 error = hibernation_snapshot(data->platform_support);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800257 if (!error)
Rafael J. Wysockicc5d2072007-10-26 01:03:33 +0200258 error = put_user(in_suspend, (int __user *)arg);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800259 if (!error)
260 data->ready = 1;
261 break;
262
263 case SNAPSHOT_ATOMIC_RESTORE:
Rafael J. Wysocki83573762006-12-06 20:34:18 -0800264 snapshot_write_finalize(&data->handle);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800265 if (data->mode != O_WRONLY || !data->frozen ||
266 !snapshot_image_loaded(&data->handle)) {
267 error = -EPERM;
268 break;
269 }
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +0200270 error = hibernation_restore(data->platform_support);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800271 break;
272
273 case SNAPSHOT_FREE:
274 swsusp_free();
275 memset(&data->handle, 0, sizeof(struct snapshot_handle));
276 data->ready = 0;
277 break;
278
Rafael J. Wysockicc5d2072007-10-26 01:03:33 +0200279 case SNAPSHOT_PREF_IMAGE_SIZE:
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800280 case SNAPSHOT_SET_IMAGE_SIZE:
281 image_size = arg;
282 break;
283
Rafael J. Wysockiaf508b32007-10-26 00:59:31 +0200284 case SNAPSHOT_GET_IMAGE_SIZE:
285 if (!data->ready) {
286 error = -ENODATA;
287 break;
288 }
289 size = snapshot_get_image_size();
290 size <<= PAGE_SHIFT;
291 error = put_user(size, (loff_t __user *)arg);
292 break;
293
Rafael J. Wysockicc5d2072007-10-26 01:03:33 +0200294 case SNAPSHOT_AVAIL_SWAP_SIZE:
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800295 case SNAPSHOT_AVAIL_SWAP:
Rafael J. Wysockiaf508b32007-10-26 00:59:31 +0200296 size = count_swap_pages(data->swap, 1);
297 size <<= PAGE_SHIFT;
298 error = put_user(size, (loff_t __user *)arg);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800299 break;
300
Rafael J. Wysockicc5d2072007-10-26 01:03:33 +0200301 case SNAPSHOT_ALLOC_SWAP_PAGE:
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800302 case SNAPSHOT_GET_SWAP_PAGE:
303 if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
304 error = -ENODEV;
305 break;
306 }
Rafael J. Wysockid1d241c2007-05-06 14:50:47 -0700307 offset = alloc_swapdev_block(data->swap);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800308 if (offset) {
309 offset <<= PAGE_SHIFT;
Rafael J. Wysockicc5d2072007-10-26 01:03:33 +0200310 error = put_user(offset, (loff_t __user *)arg);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800311 } else {
312 error = -ENOSPC;
313 }
314 break;
315
316 case SNAPSHOT_FREE_SWAP_PAGES:
317 if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
318 error = -ENODEV;
319 break;
320 }
Rafael J. Wysockid1d241c2007-05-06 14:50:47 -0700321 free_all_swap_pages(data->swap);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800322 break;
323
Rafael J. Wysocki96f73742007-10-26 01:02:15 +0200324 case SNAPSHOT_SET_SWAP_FILE: /* This ioctl is deprecated */
Rafael J. Wysockid1d241c2007-05-06 14:50:47 -0700325 if (!swsusp_swap_in_use()) {
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800326 /*
327 * User space encodes device types as two-byte values,
328 * so we need to recode them
329 */
330 if (old_decode_dev(arg)) {
Rafael J. Wysocki7bf23682007-01-05 16:36:28 -0800331 data->swap = swap_type_of(old_decode_dev(arg),
332 0, NULL);
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800333 if (data->swap < 0)
334 error = -ENODEV;
335 } else {
336 data->swap = -1;
337 error = -EINVAL;
338 }
339 } else {
340 error = -EPERM;
341 }
342 break;
343
Luca Tettamanti9b238202006-03-23 03:00:09 -0800344 case SNAPSHOT_S2RAM:
345 if (!data->frozen) {
346 error = -EPERM;
347 break;
348 }
Rafael J. Wysocki6c961df2007-07-19 01:47:38 -0700349 /*
350 * Tasks are frozen and the notifiers have been called with
351 * PM_HIBERNATION_PREPARE
352 */
353 error = suspend_devices_and_enter(PM_SUSPEND_MEM);
Luca Tettamanti9b238202006-03-23 03:00:09 -0800354 break;
355
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +0200356 case SNAPSHOT_PLATFORM_SUPPORT:
357 data->platform_support = !!arg;
358 break;
359
360 case SNAPSHOT_POWER_OFF:
361 if (data->platform_support)
362 error = hibernation_platform_enter();
363 break;
364
365 case SNAPSHOT_PMOPS: /* This ioctl is deprecated */
Rafael J. Wysocki2b5b09b2007-02-10 01:43:35 -0800366 error = -EINVAL;
367
Stefan Seyfried35926952006-12-06 20:34:06 -0800368 switch (arg) {
369
370 case PMOPS_PREPARE:
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +0200371 data->platform_support = 1;
Rafael J. Wysocki7777fab2007-07-19 01:47:29 -0700372 error = 0;
Stefan Seyfried35926952006-12-06 20:34:06 -0800373 break;
374
375 case PMOPS_ENTER:
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +0200376 if (data->platform_support)
Rafael J. Wysocki7777fab2007-07-19 01:47:29 -0700377 error = hibernation_platform_enter();
Stefan Seyfried35926952006-12-06 20:34:06 -0800378 break;
379
380 case PMOPS_FINISH:
Rafael J. Wysockieb57c1c2007-10-26 01:01:10 +0200381 if (data->platform_support)
Rafael J. Wysocki2b5b09b2007-02-10 01:43:35 -0800382 error = 0;
Stefan Seyfried35926952006-12-06 20:34:06 -0800383 break;
384
385 default:
386 printk(KERN_ERR "SNAPSHOT_PMOPS: invalid argument %ld\n", arg);
Stefan Seyfried35926952006-12-06 20:34:06 -0800387
388 }
389 break;
390
Rafael J. Wysocki37b2ba12006-12-06 20:34:15 -0800391 case SNAPSHOT_SET_SWAP_AREA:
Rafael J. Wysockid1d241c2007-05-06 14:50:47 -0700392 if (swsusp_swap_in_use()) {
Rafael J. Wysocki37b2ba12006-12-06 20:34:15 -0800393 error = -EPERM;
394 } else {
395 struct resume_swap_area swap_area;
396 dev_t swdev;
397
398 error = copy_from_user(&swap_area, (void __user *)arg,
399 sizeof(struct resume_swap_area));
400 if (error) {
401 error = -EFAULT;
402 break;
403 }
404
405 /*
406 * User space encodes device types as two-byte values,
407 * so we need to recode them
408 */
409 swdev = old_decode_dev(swap_area.dev);
410 if (swdev) {
411 offset = swap_area.offset;
Rafael J. Wysocki7bf23682007-01-05 16:36:28 -0800412 data->swap = swap_type_of(swdev, offset, NULL);
Rafael J. Wysocki37b2ba12006-12-06 20:34:15 -0800413 if (data->swap < 0)
414 error = -ENODEV;
415 } else {
416 data->swap = -1;
417 error = -EINVAL;
418 }
419 }
420 break;
421
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800422 default:
423 error = -ENOTTY;
424
425 }
Rafael J. Wysocki25f2f3d2008-06-11 22:09:45 +0200426
427 mutex_unlock(&pm_mutex);
428
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800429 return error;
430}
431
Helge Deller15ad7cd2006-12-06 20:40:36 -0800432static const struct file_operations snapshot_fops = {
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800433 .open = snapshot_open,
434 .release = snapshot_release,
435 .read = snapshot_read,
436 .write = snapshot_write,
437 .llseek = no_llseek,
Alan Cox52d11022008-06-11 22:07:52 +0200438 .unlocked_ioctl = snapshot_ioctl,
Rafael J. Wysocki6e1819d2006-03-23 03:00:03 -0800439};
440
441static struct miscdevice snapshot_device = {
442 .minor = SNAPSHOT_MINOR,
443 .name = "snapshot",
444 .fops = &snapshot_fops,
445};
446
447static int __init snapshot_device_init(void)
448{
449 return misc_register(&snapshot_device);
450};
451
452device_initcall(snapshot_device_init);