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
39 typedef unsigned short cfs_rdev_t;
41 typedef unsigned int cfs_major_nr_t;
42 typedef unsigned int cfs_minor_nr_t;
46 #define MINORMASK ((1U << MINORBITS) - 1)
48 #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
49 #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
51 #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
54 static inline cfs_rdev_t cfs_rdev_build(cfs_major_nr_t major, cfs_minor_nr_t minor)
56 return MKDEV(major, minor);
59 static inline cfs_major_nr_t cfs_rdev_major(cfs_rdev_t rdev)
64 static inline cfs_minor_nr_t cfs_rdev_minor(cfs_rdev_t rdev)
72 struct file_operations
74 loff_t (*lseek)(struct file * file, loff_t offset, int origin);
75 ssize_t (*read) (struct file * file, char * buf, size_t nbytes, loff_t *ppos);
76 ssize_t (*write)(struct file * file, const char * buffer,
77 size_t count, loff_t *ppos);
78 int (*ioctl) (struct file *, unsigned int, ulong_ptr);
79 int (*open) (struct file *);
80 int (*release) (struct file *);
85 cfs_handle_t f_handle;
90 //struct list_head f_list;
91 //struct dentry * f_dentry;
93 cfs_proc_entry_t * proc_dentry;
94 cfs_file_operations_t * f_op;
98 unsigned int f_uid, f_gid;
109 #define cfs_filp_size(f) ((f)->f_size)
110 #define cfs_filp_poff(f) (&(f)->f_pos)
112 cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err);
113 int cfs_filp_close(cfs_file_t *fp);
114 int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
115 int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
116 int cfs_filp_fsync(cfs_file_t *fp);
117 int cfs_get_file(cfs_file_t *fp);
118 int cfs_put_file(cfs_file_t *fp);
119 int cfs_file_count(cfs_file_t *fp);
127 typedef struct file_lock{
135 #define CFS_INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
136 #define CFS_OFFSET_MAX CFS_INT_LIMIT(loff_t)
138 #define cfs_flock_type(fl) ((fl)->fl_type)
139 #define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
140 #define cfs_flock_pid(fl) ((fl)->fl_pid)
141 #define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
142 #define cfs_flock_start(fl) ((fl)->fl_start)
143 #define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
144 #define cfs_flock_end(fl) ((fl)->fl_end)
145 #define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
147 #define ATTR_MODE 0x0001
148 #define ATTR_UID 0x0002
149 #define ATTR_GID 0x0004
150 #define ATTR_SIZE 0x0008
151 #define ATTR_ATIME 0x0010
152 #define ATTR_MTIME 0x0020
153 #define ATTR_CTIME 0x0040
154 #define ATTR_ATIME_SET 0x0080
155 #define ATTR_MTIME_SET 0x0100
156 #define ATTR_FORCE 0x0200 /* Not a change, but a change it */
157 #define ATTR_ATTR_FLAG 0x0400
158 #define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
159 #define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
160 //#define ATTR_CTIME_SET 0x2000
161 #define ATTR_BLOCKS 0x4000
163 #define in_group_p(x) (0)
170 void proc_destroy_fs();
177 static inline void *ERR_PTR(long_ptr error)
179 return (void *) error;
182 static inline long_ptr PTR_ERR(const void *ptr)
184 return (long_ptr) ptr;
187 static inline long_ptr IS_ERR(const void *ptr)
189 return (ulong_ptr)ptr > (ulong_ptr)-1000L;
192 #else /* !__KERNEL__ */
195 #define CREATE_ALWAYS 2
196 #define OPEN_EXISTING 3
197 #define OPEN_ALWAYS 4
198 #define TRUNCATE_EXISTING 5
200 #define SECTION_QUERY 0x0001
201 #define SECTION_MAP_WRITE 0x0002
202 #define SECTION_MAP_READ 0x0004
203 #define SECTION_MAP_EXECUTE 0x0008
204 #define SECTION_EXTEND_SIZE 0x0010
206 #define FILE_MAP_COPY SECTION_QUERY
207 #define FILE_MAP_WRITE SECTION_MAP_WRITE
208 #define FILE_MAP_READ SECTION_MAP_READ
209 #define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
216 IN LPCSTR lpFileName,
217 IN DWORD dwDesiredAccess,
218 IN DWORD dwShareMode,
219 IN PVOID lpSecurityAttributes,
220 IN DWORD dwCreationDisposition,
221 IN DWORD dwFlagsAndAttributes,
222 IN HANDLE hTemplateFile
225 #define CreateFile CreateFileA
231 IN OUT HANDLE hObject
239 IN PVOID lpFileMappingAttributes,
241 IN DWORD dwMaximumSizeHigh,
242 IN DWORD dwMaximumSizeLow,
245 #define CreateFileMapping CreateFileMappingA
252 OUT DWORD * lpFileSizeHigh
259 IN HANDLE hFileMappingObject,
260 IN DWORD dwDesiredAccess,
261 IN DWORD dwFileOffsetHigh,
262 IN DWORD dwFileOffsetLow,
263 IN SIZE_T dwNumberOfBytesToMap
270 IN PVOID lpBaseAddress
273 #endif /* __KERNEL__ */
280 #endif /* __LIBCFS_WINNT_CFS_FS_H__*/