This patch adds a user space interface for swsusp. The interface is basedon the special character device allowing user space processes to performsuspend and resume-related operations with the help of some ioctls andthe read()/write() functions. Additionally it allows these processes toallocate swap pages so that they know which sectors of the resume partitionare available to them (it is also possible to free the allocated swap pages).

Currently the major number of the device is allocated dynamically,so it is exported via sysfs for convenience, but I'd like the device tohave a well-defined major number in the future, if possible/acceptable.

The interface uses the same low-level snapshot-handling functions thatare used by the in-kernel swap-writing/reading code of swsusp.

/**- * Check whether the swap device is the specified resume- * device, irrespective of whether they are specified by- * identical names.+ * is_device - check whether the specified device is a swap device,+ * irrespective of whether they are specified by identical names. *- * (Thus, device inode aliasing is allowed. You can say /dev/hda4- * instead of /dev/ide/host0/bus0/target0/lun0/part4 [eg. for devfs]- * and they'll be considered the same device. This was *necessary* for- * devfs, since the resume code could only recognize the form /dev/hda4,- * but the suspend code would see the long name.)+ * (Thus, device inode aliasing is allowed. You can say /dev/hda4+ * instead of /dev/ide/host0/bus0/target0/lun0/part4 [eg. for devfs]+ * and they'll be considered the same device. This was *necessary* for+ * devfs, since the resume code could only recognize the form /dev/hda4,+ * but the suspend code would see the long name.) */

/**- * The bitmap is used for tracing allocated swap pages- *- * The entire bitmap consists of a number of bitmap_page- * structures linked with the help of the .next member.- * Thus each page can be allocated individually, so we only- * need to make 0-order memory allocations to create- * the bitmap.- */--#define BITMAP_PAGE_SIZE (PAGE_SIZE - sizeof(void *))-#define BITMAP_PAGE_CHUNKS (BITMAP_PAGE_SIZE / sizeof(long))-#define BITS_PER_CHUNK (sizeof(long) * 8)-#define BITMAP_PAGE_BITS (BITMAP_PAGE_CHUNKS * BITS_PER_CHUNK)--struct bitmap_page {- unsigned long chunks[BITMAP_PAGE_CHUNKS];- struct bitmap_page *next;-};--/** * The following functions are used for tracing the allocated * swap pages, so that they can be freed in case of an error. * * The functions operate on a linked bitmap structure defined- * above+ * in power.h */