4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * libcfs/include/libcfs/winnt/winnt-fs.h
36 * File operations & routines.
39 #ifndef __LIBCFS_WINNT_CFS_FS_H__
40 #define __LIBCFS_WINNT_CFS_FS_H__
42 #ifndef __LIBCFS_LIBCFS_H__
43 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
48 #define MINORMASK ((1U << MINORBITS) - 1)
50 #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
51 #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
53 #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
55 #define PATH_MAX (260)
69 /* Internal kernel extensions */
72 #define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
74 /* File is being opened for execution. Primary users of this flag are
75 distributed filesystems that can use it to achieve correct ETXTBUSY
76 behavior for cross-node execution/opening_for_writing of files */
83 #define READA 2 /* read-ahead - don't block if no resources */
84 #define SWRITE 3 /* for ll_rw_block() - wait for buffer lock */
85 #define SPECIAL 4 /* For non-blockdevice requests in request queue */
86 #define READ_SYNC (READ | (1 << BIO_RW_SYNC))
87 #define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))
88 #define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER))
90 struct file_operations
93 loff_t (*llseek)(struct file * file, loff_t offset, int origin);
94 ssize_t (*read) (struct file * file, char * buf, size_t nbytes, loff_t *ppos);
95 ssize_t (*write)(struct file * file, const char * buffer,
96 size_t count, loff_t *ppos);
97 int (*ioctl) (struct file *, unsigned int, ulong_ptr_t);
98 int (*open) (struct inode*, struct file *);
99 int (*release) (struct inode*, struct file *);
104 cfs_handle_t f_handle;
105 unsigned int f_flags;
111 unsigned int f_uid, f_gid;
116 //struct list_head f_list;
117 struct dentry * f_dentry;
119 cfs_proc_entry_t * proc_dentry;
120 cfs_file_operations_t * f_op;
123 struct inode * f_inode;
128 #define cfs_filp_size(f) ((f)->f_size)
129 #define cfs_filp_poff(f) (&(f)->f_pos)
131 cfs_file_t *cfs_filp_open(const char *name, int flags, int mode, int *err);
132 int cfs_filp_close(cfs_file_t *fp);
133 int cfs_filp_read(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
134 int cfs_filp_write(cfs_file_t *fp, void *buf, size_t nbytes, loff_t *pos);
135 int cfs_filp_fsync(cfs_file_t *fp);
136 int cfs_get_file(cfs_file_t *fp);
137 int cfs_put_file(cfs_file_t *fp);
138 int cfs_file_count(cfs_file_t *fp);
139 #define cfs_filp_unlink(x, y) (KdBreakPoint(),0)
144 typedef struct file_lock{
152 #define CFS_INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
153 #define CFS_OFFSET_MAX CFS_INT_LIMIT(loff_t)
155 #define cfs_flock_type(fl) ((fl)->fl_type)
156 #define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
157 #define cfs_flock_pid(fl) ((fl)->fl_pid)
158 #define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
159 #define cfs_flock_start(fl) ((fl)->fl_start)
160 #define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
161 #define cfs_flock_end(fl) ((fl)->fl_end)
162 #define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
164 #define ATTR_MODE 0x0001
165 #define ATTR_UID 0x0002
166 #define ATTR_GID 0x0004
167 #define ATTR_SIZE 0x0008
168 #define ATTR_ATIME 0x0010
169 #define ATTR_MTIME 0x0020
170 #define ATTR_CTIME 0x0040
171 #define ATTR_ATIME_SET 0x0080
172 #define ATTR_MTIME_SET 0x0100
173 #define ATTR_FORCE 0x0200 /* Not a change, but a change it */
174 #define ATTR_ATTR_FLAG 0x0400
175 #define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
176 #define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
177 //#define ATTR_CTIME_SET 0x2000
180 * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
181 * ATTR_* attributes (see bug 13828): lustre/include/winnt/lustre_compat25.h
183 /* #define ATTR_BLOCKS 0x4000 */
184 #define ATTR_BLOCKS (1 << 27)
186 #define ATTR_KILL_SUID 0
187 #define ATTR_KILL_SGID 0
191 #define in_group_p(x) (0)
194 /* VFS structures for windows */
200 #define S_IFMT 00170000
201 #define S_IFSOCK 0140000
202 #define S_IFLNK 0120000
203 #define S_IFREG 0100000
204 #define S_IFBLK 0060000
205 #define S_IFDIR 0040000
206 #define S_IFCHR 0020000
207 #define S_IFIFO 0010000
208 #define S_ISUID 0004000
209 #define S_ISGID 0002000
210 #define S_ISVTX 0001000
212 /* Inode flags - they have nothing to superblock flags now */
214 #define S_SYNC 1 /* Writes are synced at once */
215 #define S_NOATIME 2 /* Do not update access times */
216 #define S_APPEND 4 /* Append-only file */
217 #define S_IMMUTABLE 8 /* Immutable file */
218 #define S_DEAD 16 /* removed, but still open directory */
219 #define S_NOQUOTA 32 /* Inode is not counted to quota */
220 #define S_DIRSYNC 64 /* Directory modifications are synchronous */
221 #define S_NOCMTIME 128 /* Do not update file c/mtime */
222 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
223 #define S_PRIVATE 512 /* Inode is fs-internal */
230 struct timespec i_atime;
231 struct timespec i_ctime;
232 struct timespec i_mtime;
233 struct timespec i_dtime;
245 #define I_FREEING 0x0001
248 cfs_atomic_t d_count;
253 struct inode * d_inode;
254 struct dentry* d_parent;
257 extern struct dentry *dget(struct dentry *de);
258 extern void dput(struct dentry *de);
259 static __inline struct dentry *lookup_one_len(const char *name, struct dentry *de, int len)
261 cfs_enter_debugger();
265 static inline loff_t i_size_read(const struct inode *inode)
267 cfs_enter_debugger();
268 return inode->i_size;
271 static inline void i_size_write(struct inode *inode, loff_t i_size)
273 cfs_enter_debugger();
274 inode->i_size = i_size;
277 typedef struct cfs_kstatfs {
297 struct dentry * mnt_root;
298 struct super_block *mnt_sb;
303 * quota definitions (linux/quota.h)
307 #define USRQUOTA 0 /* element used for user quotas */
308 #define GRPQUOTA 1 /* element used for group quotas */
315 typedef int (read_proc_t)(char *page, char **start, off_t off,
316 int count, int *eof, void *data);
318 struct file; /* forward ref */
319 typedef int (write_proc_t)(struct file *file, const char *buffer,
320 unsigned long count, void *data);
322 void proc_destory_subtree(cfs_proc_entry_t *entry);
325 void proc_destroy_fs();
331 HANDLE cfs_open_current_thread();
332 void cfs_close_thread_handle(HANDLE handle);
333 KAFFINITY cfs_query_thread_affinity();
334 int cfs_set_thread_affinity(KAFFINITY affinity);
335 int cfs_tie_thread_to_cpu(int cpu);
336 typedef PVOID mm_segment_t;
341 int cfs_set_thread_priority(KPRIORITY priority);
343 #define MAKE_MM_SEG(s) ((mm_segment_t)(ulong_ptr_t)(s))
344 #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL)
345 #define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
347 #define get_ds() (KERNEL_DS)
348 #define set_fs(x) do {} while(0)
349 #define get_fs() (NULL)
352 * radix tree (linux/radix_tree.h)
355 /* radix tree root structure */
356 struct radix_tree_root {
357 RTL_GENERIC_TABLE table;
360 /* #define RADIX_TREE_INIT(mask) {0}
362 #define RADIX_TREE(name, mask) \
363 struct radix_tree_root name RADIX_TREE_INIT(mask) */
365 VOID RadixInitTable(IN PRTL_GENERIC_TABLE Table);
366 #define INIT_RADIX_TREE(root, mask) RadixInitTable(&((root)->table))
368 /* all radix tree routines should be protected by external locks */
370 radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
371 unsigned long first_index, unsigned int max_items);
372 void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index);
373 int radix_tree_insert(struct radix_tree_root *root, unsigned long index,
375 void *radix_tree_delete(struct radix_tree_root *root, unsigned long index);
377 #else /* !__KERNEL__ */
379 #if !defined(_WINDOWS_)
382 #define CREATE_ALWAYS 2
383 #define OPEN_EXISTING 3
384 #define OPEN_ALWAYS 4
385 #define TRUNCATE_EXISTING 5
387 #define SECTION_QUERY 0x0001
388 #define SECTION_MAP_WRITE 0x0002
389 #define SECTION_MAP_READ 0x0004
390 #define SECTION_MAP_EXECUTE 0x0008
391 #define SECTION_EXTEND_SIZE 0x0010
393 #define FILE_MAP_COPY SECTION_QUERY
394 #define FILE_MAP_WRITE SECTION_MAP_WRITE
395 #define FILE_MAP_READ SECTION_MAP_READ
396 #define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
403 IN LPCSTR lpFileName,
404 IN DWORD dwDesiredAccess,
405 IN DWORD dwShareMode,
406 IN PVOID lpSecurityAttributes,
407 IN DWORD dwCreationDisposition,
408 IN DWORD dwFlagsAndAttributes,
409 IN HANDLE hTemplateFile
412 #define CreateFile CreateFileA
418 IN OUT HANDLE hObject
433 IN PVOID lpFileMappingAttributes,
435 IN DWORD dwMaximumSizeHigh,
436 IN DWORD dwMaximumSizeLow,
439 #define CreateFileMapping CreateFileMappingA
446 OUT DWORD * lpFileSizeHigh
453 IN HANDLE hFileMappingObject,
454 IN DWORD dwDesiredAccess,
455 IN DWORD dwFileOffsetHigh,
456 IN DWORD dwFileOffsetLow,
457 IN SIZE_T dwNumberOfBytesToMap
464 IN PVOID lpBaseAddress
468 #endif /* __KERNEL__ */
478 #define ERR_PTR(error) ((void *)(long_ptr_t)(error))
479 #define PTR_ERR(ptr) ((long)(long_ptr_t) (ptr))
480 #define IS_ERR(ptr) ((long)(((ulong_ptr_t) (ptr)) > (ulong_ptr_t)(-1000L)))
482 #endif /* __LIBCFS_WINNT_CFS_FS_H__*/