vserver 1.9.3
[linux-2.6.git] / arch / um / include / ubd_user.h
1 /* 
2  * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3  * Copyright (C) 2001 RidgeRun, Inc (glonnon@ridgerun.com)
4  * Licensed under the GPL
5  */
6
7 #ifndef __UM_UBD_USER_H
8 #define __UM_UBD_USER_H
9
10 #include "os.h"
11
12 enum ubd_req { UBD_READ, UBD_WRITE, UBD_MMAP };
13
14 struct io_thread_req {
15         enum ubd_req op;
16         int fds[2];
17         unsigned long offsets[2];
18         unsigned long long offset;
19         unsigned long length;
20         char *buffer;
21         int sectorsize;
22         unsigned long sector_mask;
23         unsigned long long cow_offset;
24         unsigned long bitmap_words[2];
25         int map_fd;
26         unsigned long long map_offset;
27         int error;
28 };
29
30 extern int open_ubd_file(char *file, struct openflags *openflags, 
31                          char **backing_file_out, int *bitmap_offset_out, 
32                          unsigned long *bitmap_len_out, int *data_offset_out,
33                          int *create_cow_out);
34 extern int create_cow_file(char *cow_file, char *backing_file, 
35                            struct openflags flags, int sectorsize, 
36                            int alignment, int *bitmap_offset_out,
37                            unsigned long *bitmap_len_out,
38                            int *data_offset_out);
39 extern int read_cow_bitmap(int fd, void *buf, int offset, int len);
40 extern int read_ubd_fs(int fd, void *buffer, int len);
41 extern int write_ubd_fs(int fd, char *buffer, int len);
42 extern int start_io_thread(unsigned long sp, int *fds_out);
43 extern void do_io(struct io_thread_req *req);
44
45 static inline int ubd_test_bit(__u64 bit, unsigned char *data)
46 {
47         __u64 n;
48         int bits, off;
49
50         bits = sizeof(data[0]) * 8;
51         n = bit / bits;
52         off = bit % bits;
53         return((data[n] & (1 << off)) != 0);
54 }
55
56 static inline void ubd_set_bit(__u64 bit, unsigned char *data)
57 {
58         __u64 n;
59         int bits, off;
60
61         bits = sizeof(data[0]) * 8;
62         n = bit / bits;
63         off = bit % bits;
64         data[n] |= (1 << off);
65 }
66
67
68 #endif
69
70 /*
71  * Overrides for Emacs so that we follow Linus's tabbing style.
72  * Emacs will notice this stuff at the end of the file and automatically
73  * adjust the settings for this buffer only.  This must remain at the end
74  * of the file.
75  * ---------------------------------------------------------------------------
76  * Local variables:
77  * c-file-style: "linux"
78  * End:
79  */