ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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 };
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 cow_offset;
24         unsigned long bitmap_words[2];
25         int error;
26 };
27
28 extern int open_ubd_file(char *file, struct openflags *openflags, 
29                          char **backing_file_out, int *bitmap_offset_out, 
30                          unsigned long *bitmap_len_out, int *data_offset_out,
31                          int *create_cow_out);
32 extern int create_cow_file(char *cow_file, char *backing_file, 
33                            struct openflags flags, int sectorsize, 
34                            int *bitmap_offset_out, 
35                            unsigned long *bitmap_len_out,
36                            int *data_offset_out);
37 extern int read_cow_bitmap(int fd, void *buf, int offset, int len);
38 extern int read_ubd_fs(int fd, void *buffer, int len);
39 extern int write_ubd_fs(int fd, char *buffer, int len);
40 extern int start_io_thread(unsigned long sp, int *fds_out);
41 extern void do_io(struct io_thread_req *req);
42 extern int ubd_is_dir(char *file);
43
44 static inline int ubd_test_bit(__u64 bit, unsigned char *data)
45 {
46         __u64 n;
47         int bits, off;
48
49         bits = sizeof(data[0]) * 8;
50         n = bit / bits;
51         off = bit % bits;
52         return((data[n] & (1 << off)) != 0);
53 }
54
55 static inline void ubd_set_bit(__u64 bit, unsigned char *data)
56 {
57         __u64 n;
58         int bits, off;
59
60         bits = sizeof(data[0]) * 8;
61         n = bit / bits;
62         off = bit % bits;
63         data[n] |= (1 << off);
64 }
65
66
67 #endif
68
69 /*
70  * Overrides for Emacs so that we follow Linus's tabbing style.
71  * Emacs will notice this stuff at the end of the file and automatically
72  * adjust the settings for this buffer only.  This must remain at the end
73  * of the file.
74  * ---------------------------------------------------------------------------
75  * Local variables:
76  * c-file-style: "linux"
77  * End:
78  */