1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * libcfs/include/libcfs/winnt/winnt-fs.h
38 * File operations & routines.
41 #ifndef __LIBCFS_WINNT_CFS_FS_H__
42 #define __LIBCFS_WINNT_CFS_FS_H__
44 #ifndef __LIBCFS_LIBCFS_H__
45 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
50 #define MINORMASK ((1U << MINORBITS) - 1)
52 #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
53 #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
55 #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
60 struct file_operations
62 loff_t (*lseek)(struct file * file, loff_t offset, int origin);
63 ssize_t (*read) (struct file * file, char * buf, size_t nbytes, loff_t *ppos);
64 ssize_t (*write)(struct file * file, const char * buffer,
65 size_t count, loff_t *ppos);
66 int (*ioctl) (struct file *, unsigned int, ulong_ptr);
67 int (*open) (struct file *);
68 int (*release) (struct file *);
73 cfs_handle_t f_handle;
78 //struct list_head f_list;
79 //struct dentry * f_dentry;
81 cfs_proc_entry_t * proc_dentry;
82 cfs_file_operations_t * f_op;
86 unsigned int f_uid, f_gid;
97 #define cfs_filp_size(f) ((f)->f_size)
98 #define cfs_filp_poff(f) (&(f)->f_pos)
100 cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err);
101 int cfs_filp_close(cfs_file_t *fp);
102 int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
103 int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
104 int cfs_filp_fsync(cfs_file_t *fp);
105 int cfs_get_file(cfs_file_t *fp);
106 int cfs_put_file(cfs_file_t *fp);
107 int cfs_file_count(cfs_file_t *fp);
115 typedef struct file_lock{
123 #define CFS_INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
124 #define CFS_OFFSET_MAX CFS_INT_LIMIT(loff_t)
126 #define cfs_flock_type(fl) ((fl)->fl_type)
127 #define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
128 #define cfs_flock_pid(fl) ((fl)->fl_pid)
129 #define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
130 #define cfs_flock_start(fl) ((fl)->fl_start)
131 #define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
132 #define cfs_flock_end(fl) ((fl)->fl_end)
133 #define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
135 #define ATTR_MODE 0x0001
136 #define ATTR_UID 0x0002
137 #define ATTR_GID 0x0004
138 #define ATTR_SIZE 0x0008
139 #define ATTR_ATIME 0x0010
140 #define ATTR_MTIME 0x0020
141 #define ATTR_CTIME 0x0040
142 #define ATTR_ATIME_SET 0x0080
143 #define ATTR_MTIME_SET 0x0100
144 #define ATTR_FORCE 0x0200 /* Not a change, but a change it */
145 #define ATTR_ATTR_FLAG 0x0400
146 #define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
147 #define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
148 //#define ATTR_CTIME_SET 0x2000
149 #define ATTR_BLOCKS 0x4000
150 #define ATTR_KILL_SUID 0
151 #define ATTR_KILL_SGID 0
153 #define in_group_p(x) (0)
160 void proc_destroy_fs();
167 static inline void *ERR_PTR(long_ptr error)
169 return (void *) error;
172 static inline long_ptr PTR_ERR(const void *ptr)
174 return (long_ptr) ptr;
177 static inline long_ptr IS_ERR(const void *ptr)
179 return (ulong_ptr)ptr > (ulong_ptr)-1000L;
182 #else /* !__KERNEL__ */
185 #define CREATE_ALWAYS 2
186 #define OPEN_EXISTING 3
187 #define OPEN_ALWAYS 4
188 #define TRUNCATE_EXISTING 5
190 #define SECTION_QUERY 0x0001
191 #define SECTION_MAP_WRITE 0x0002
192 #define SECTION_MAP_READ 0x0004
193 #define SECTION_MAP_EXECUTE 0x0008
194 #define SECTION_EXTEND_SIZE 0x0010
196 #define FILE_MAP_COPY SECTION_QUERY
197 #define FILE_MAP_WRITE SECTION_MAP_WRITE
198 #define FILE_MAP_READ SECTION_MAP_READ
199 #define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
206 IN LPCSTR lpFileName,
207 IN DWORD dwDesiredAccess,
208 IN DWORD dwShareMode,
209 IN PVOID lpSecurityAttributes,
210 IN DWORD dwCreationDisposition,
211 IN DWORD dwFlagsAndAttributes,
212 IN HANDLE hTemplateFile
215 #define CreateFile CreateFileA
221 IN OUT HANDLE hObject
229 IN PVOID lpFileMappingAttributes,
231 IN DWORD dwMaximumSizeHigh,
232 IN DWORD dwMaximumSizeLow,
235 #define CreateFileMapping CreateFileMappingA
242 OUT DWORD * lpFileSizeHigh
249 IN HANDLE hFileMappingObject,
250 IN DWORD dwDesiredAccess,
251 IN DWORD dwFileOffsetHigh,
252 IN DWORD dwFileOffsetLow,
253 IN SIZE_T dwNumberOfBytesToMap
260 IN PVOID lpBaseAddress
263 #endif /* __KERNEL__ */
270 #endif /* __LIBCFS_WINNT_CFS_FS_H__*/