1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
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 * Basic library routines.
25 #ifndef __LIBCFS_LINUX_CFS_FS_H__
26 #define __LIBCFS_LINUX_CFS_FS_H__
28 #ifndef __LIBCFS_LIBCFS_H__
29 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
34 #include <linux/stat.h>
35 #include <linux/mount.h>
36 #else /* !__KERNEL__ */
43 #include <sys/mount.h>
45 #endif /* __KERNEL__ */
47 typedef struct file cfs_file_t;
48 typedef struct dentry cfs_dentry_t;
49 typedef struct dirent64 cfs_dirent_t;
52 #define cfs_filp_size(f) (i_size_read((f)->f_dentry->d_inode))
53 #define cfs_filp_poff(f) (&(f)->f_pos)
56 * XXX Do we need to parse flags and mode in cfs_filp_open?
58 cfs_file_t *cfs_filp_open (const char *name, int flags, int mode, int *err);
59 #define cfs_filp_close(f) filp_close(f, NULL)
60 #define cfs_filp_read(fp, buf, size, pos) (fp)->f_op->read((fp), (buf), (size), pos)
61 #define cfs_filp_write(fp, buf, size, pos) (fp)->f_op->write((fp), (buf), (size), pos)
62 #define cfs_filp_fsync(fp) (fp)->f_op->fsync((fp), (fp)->f_dentry, 1)
64 #define cfs_get_file(f) get_file(f)
65 #define cfs_put_file(f) fput(f)
66 #define cfs_file_count(f) file_count(f)
68 typedef struct file_lock cfs_flock_t;
69 #define cfs_flock_type(fl) ((fl)->fl_type)
70 #define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
71 #define cfs_flock_pid(fl) ((fl)->fl_pid)
72 #define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
73 #define cfs_flock_start(fl) ((fl)->fl_start)
74 #define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
75 #define cfs_flock_end(fl) ((fl)->fl_end)
76 #define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
78 ssize_t cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset);