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.
35 # define DEBUG_SUBSYSTEM S_LNET
38 #include <linux/kdev_t.h>
39 #include <linux/ctype.h>
40 #include <asm/uaccess.h>
42 #include <libcfs/libcfs.h>
45 cfs_filp_open (const char *name, int flags, int mode, int *err)
48 * Maybe we need to handle flags and mode in the future
50 cfs_file_t *filp = NULL;
52 filp = filp_open(name, flags, mode);
57 printk(KERN_ERR "LustreError: can't open %s file: err %d\n",
66 /* write a userspace buffer to disk.
67 * NOTE: this returns 0 on success, not the number of bytes written. */
69 cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset)
76 while ((ssize_t)count > 0) {
77 size = filp->f_op->write(filp, (char *)buf, count, offset);
89 #if !(CFS_O_CREAT == O_CREAT && CFS_O_EXCL == O_EXCL && \
90 CFS_O_NOACCESS == O_NOACCESS &&\
91 CFS_O_TRUNC == O_TRUNC && CFS_O_APPEND == O_APPEND &&\
92 CFS_O_NONBLOCK == O_NONBLOCK && CFS_O_NDELAY == O_NDELAY &&\
93 CFS_O_SYNC == O_SYNC && CFS_O_ASYNC == FASYNC &&\
94 CFS_O_DIRECT == O_DIRECT && CFS_O_LARGEFILE == O_LARGEFILE &&\
95 CFS_O_DIRECTORY == O_DIRECTORY && CFS_O_NOFOLLOW == O_NOFOLLOW)
97 int cfs_oflags2univ(int flags)
101 f = flags & O_NOACCESS;
102 f |= (flags & O_CREAT) ? CFS_O_CREAT: 0;
103 f |= (flags & O_EXCL) ? CFS_O_EXCL: 0;
104 f |= (flags & O_NOCTTY) ? CFS_O_NOCTTY: 0;
105 f |= (flags & O_TRUNC) ? CFS_O_TRUNC: 0;
106 f |= (flags & O_APPEND) ? CFS_O_APPEND: 0;
107 f |= (flags & O_NONBLOCK) ? CFS_O_NONBLOCK: 0;
108 f |= (flags & O_SYNC)? CFS_O_SYNC: 0;
109 f |= (flags & FASYNC)? CFS_O_ASYNC: 0;
110 f |= (flags & O_DIRECTORY)? CFS_O_DIRECTORY: 0;
111 f |= (flags & O_DIRECT)? CFS_O_DIRECT: 0;
112 f |= (flags & O_LARGEFILE)? CFS_O_LARGEFILE: 0;
113 f |= (flags & O_NOFOLLOW)? CFS_O_NOFOLLOW: 0;
114 f |= (flags & O_NOATIME)? CFS_O_NOATIME: 0;
119 int cfs_oflags2univ(int flags)
126 * XXX Liang: we don't need cfs_univ2oflags() now.
128 int cfs_univ2oflags(int flags)
133 EXPORT_SYMBOL(cfs_filp_open);
134 EXPORT_SYMBOL(cfs_user_write);
135 EXPORT_SYMBOL(cfs_oflags2univ);
136 EXPORT_SYMBOL(cfs_univ2oflags);