1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=4:tabstop=4:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * File operations & routines.
25 #ifndef __LIBCFS_WINNT_CFS_FS_H__
26 #define __LIBCFS_WINNT_CFS_FS_H__
28 #ifndef __LIBCFS_LIBCFS_H__
29 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
34 #define MINORMASK ((1U << MINORBITS) - 1)
36 #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
37 #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
39 #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
44 struct file_operations
46 loff_t (*lseek)(struct file * file, loff_t offset, int origin);
47 ssize_t (*read) (struct file * file, char * buf, size_t nbytes, loff_t *ppos);
48 ssize_t (*write)(struct file * file, const char * buffer,
49 size_t count, loff_t *ppos);
50 int (*ioctl) (struct file *, unsigned int, ulong_ptr);
51 int (*open) (struct file *);
52 int (*release) (struct file *);
57 cfs_handle_t f_handle;
62 //struct list_head f_list;
63 //struct dentry * f_dentry;
65 cfs_proc_entry_t * proc_dentry;
66 cfs_file_operations_t * f_op;
70 unsigned int f_uid, f_gid;
81 #define cfs_filp_size(f) ((f)->f_size)
82 #define cfs_filp_poff(f) (&(f)->f_pos)
84 cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err);
85 int cfs_filp_close(cfs_file_t *fp);
86 int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
87 int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
88 int cfs_filp_fsync(cfs_file_t *fp);
89 int cfs_get_file(cfs_file_t *fp);
90 int cfs_put_file(cfs_file_t *fp);
91 int cfs_file_count(cfs_file_t *fp);
99 typedef struct file_lock{
107 #define CFS_INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
108 #define CFS_OFFSET_MAX CFS_INT_LIMIT(loff_t)
110 #define cfs_flock_type(fl) ((fl)->fl_type)
111 #define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
112 #define cfs_flock_pid(fl) ((fl)->fl_pid)
113 #define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
114 #define cfs_flock_start(fl) ((fl)->fl_start)
115 #define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
116 #define cfs_flock_end(fl) ((fl)->fl_end)
117 #define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
119 #define ATTR_MODE 0x0001
120 #define ATTR_UID 0x0002
121 #define ATTR_GID 0x0004
122 #define ATTR_SIZE 0x0008
123 #define ATTR_ATIME 0x0010
124 #define ATTR_MTIME 0x0020
125 #define ATTR_CTIME 0x0040
126 #define ATTR_ATIME_SET 0x0080
127 #define ATTR_MTIME_SET 0x0100
128 #define ATTR_FORCE 0x0200 /* Not a change, but a change it */
129 #define ATTR_ATTR_FLAG 0x0400
130 #define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
131 #define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
132 //#define ATTR_CTIME_SET 0x2000
133 #define ATTR_BLOCKS 0x4000
134 #define ATTR_KILL_SUID 0
135 #define ATTR_KILL_SGID 0
137 #define in_group_p(x) (0)
144 void proc_destroy_fs();
151 static inline void *ERR_PTR(long_ptr error)
153 return (void *) error;
156 static inline long_ptr PTR_ERR(const void *ptr)
158 return (long_ptr) ptr;
161 static inline long_ptr IS_ERR(const void *ptr)
163 return (ulong_ptr)ptr > (ulong_ptr)-1000L;
166 #else /* !__KERNEL__ */
169 #define CREATE_ALWAYS 2
170 #define OPEN_EXISTING 3
171 #define OPEN_ALWAYS 4
172 #define TRUNCATE_EXISTING 5
174 #define SECTION_QUERY 0x0001
175 #define SECTION_MAP_WRITE 0x0002
176 #define SECTION_MAP_READ 0x0004
177 #define SECTION_MAP_EXECUTE 0x0008
178 #define SECTION_EXTEND_SIZE 0x0010
180 #define FILE_MAP_COPY SECTION_QUERY
181 #define FILE_MAP_WRITE SECTION_MAP_WRITE
182 #define FILE_MAP_READ SECTION_MAP_READ
183 #define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
190 IN LPCSTR lpFileName,
191 IN DWORD dwDesiredAccess,
192 IN DWORD dwShareMode,
193 IN PVOID lpSecurityAttributes,
194 IN DWORD dwCreationDisposition,
195 IN DWORD dwFlagsAndAttributes,
196 IN HANDLE hTemplateFile
199 #define CreateFile CreateFileA
205 IN OUT HANDLE hObject
213 IN PVOID lpFileMappingAttributes,
215 IN DWORD dwMaximumSizeHigh,
216 IN DWORD dwMaximumSizeLow,
219 #define CreateFileMapping CreateFileMappingA
226 OUT DWORD * lpFileSizeHigh
233 IN HANDLE hFileMappingObject,
234 IN DWORD dwDesiredAccess,
235 IN DWORD dwFileOffsetHigh,
236 IN DWORD dwFileOffsetLow,
237 IN SIZE_T dwNumberOfBytesToMap
244 IN PVOID lpBaseAddress
247 #endif /* __KERNEL__ */
254 #endif /* __LIBCFS_WINNT_CFS_FS_H__*/