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 [sun.com URL with a
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/linux/linux-fs.h
38 * Basic library routines.
41 #ifndef __LIBCFS_LINUX_CFS_FS_H__
42 #define __LIBCFS_LINUX_CFS_FS_H__
44 #ifndef __LIBCFS_LIBCFS_H__
45 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
50 #include <linux/stat.h>
51 #include <linux/mount.h>
52 #else /* !__KERNEL__ */
59 #include <sys/mount.h>
61 #endif /* __KERNEL__ */
63 typedef struct file cfs_file_t;
64 typedef struct dentry cfs_dentry_t;
65 typedef struct dirent64 cfs_dirent_t;
68 #define cfs_filp_size(f) (i_size_read((f)->f_dentry->d_inode))
69 #define cfs_filp_poff(f) (&(f)->f_pos)
72 * XXX Do we need to parse flags and mode in cfs_filp_open?
74 cfs_file_t *cfs_filp_open (const char *name, int flags, int mode, int *err);
75 #define cfs_filp_close(f) filp_close(f, NULL)
76 #define cfs_filp_read(fp, buf, size, pos) (fp)->f_op->read((fp), (buf), (size), pos)
77 #define cfs_filp_write(fp, buf, size, pos) (fp)->f_op->write((fp), (buf), (size), pos)
78 #define cfs_filp_fsync(fp) (fp)->f_op->fsync((fp), (fp)->f_dentry, 1)
80 #define cfs_get_file(f) get_file(f)
81 #define cfs_put_file(f) fput(f)
82 #define cfs_file_count(f) file_count(f)
84 typedef struct file_lock cfs_flock_t;
85 #define cfs_flock_type(fl) ((fl)->fl_type)
86 #define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
87 #define cfs_flock_pid(fl) ((fl)->fl_pid)
88 #define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
89 #define cfs_flock_start(fl) ((fl)->fl_start)
90 #define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
91 #define cfs_flock_end(fl) ((fl)->fl_end)
92 #define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
94 ssize_t cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset);