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 (c) 2008, 2010, Oracle and/or its affiliates. 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.
37 # define DEBUG_SUBSYSTEM S_LNET
40 #include <linux/kdev_t.h>
41 #include <linux/ctype.h>
42 #include <asm/uaccess.h>
44 #include <libcfs/libcfs.h>
47 cfs_filp_open (const char *name, int flags, int mode, int *err)
50 * Maybe we need to handle flags and mode in the future
52 cfs_file_t *filp = NULL;
54 filp = filp_open(name, flags, mode);
59 printk(KERN_ERR "LustreError: can't open %s file: err %d\n",
68 /* write a userspace buffer to disk.
69 * NOTE: this returns 0 on success, not the number of bytes written. */
71 cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset)
78 while ((ssize_t)count > 0) {
79 size = filp->f_op->write(filp, (char *)buf, count, offset);
91 #if !(CFS_O_CREAT == O_CREAT && CFS_O_EXCL == O_EXCL && \
92 CFS_O_NOACCESS == O_NOACCESS &&\
93 CFS_O_TRUNC == O_TRUNC && CFS_O_APPEND == O_APPEND &&\
94 CFS_O_NONBLOCK == O_NONBLOCK && CFS_O_NDELAY == O_NDELAY &&\
95 CFS_O_SYNC == O_SYNC && CFS_O_ASYNC == FASYNC &&\
96 CFS_O_DIRECT == O_DIRECT && CFS_O_LARGEFILE == O_LARGEFILE &&\
97 CFS_O_DIRECTORY == O_DIRECTORY && CFS_O_NOFOLLOW == O_NOFOLLOW)
99 int cfs_oflags2univ(int flags)
103 f = flags & O_NOACCESS;
104 f |= (flags & O_CREAT) ? CFS_O_CREAT: 0;
105 f |= (flags & O_EXCL) ? CFS_O_EXCL: 0;
106 f |= (flags & O_NOCTTY) ? CFS_O_NOCTTY: 0;
107 f |= (flags & O_TRUNC) ? CFS_O_TRUNC: 0;
108 f |= (flags & O_APPEND) ? CFS_O_APPEND: 0;
109 f |= (flags & O_NONBLOCK) ? CFS_O_NONBLOCK: 0;
110 f |= (flags & O_SYNC)? CFS_O_SYNC: 0;
111 f |= (flags & FASYNC)? CFS_O_ASYNC: 0;
112 f |= (flags & O_DIRECTORY)? CFS_O_DIRECTORY: 0;
113 f |= (flags & O_DIRECT)? CFS_O_DIRECT: 0;
114 f |= (flags & O_LARGEFILE)? CFS_O_LARGEFILE: 0;
115 f |= (flags & O_NOFOLLOW)? CFS_O_NOFOLLOW: 0;
116 f |= (flags & O_NOATIME)? CFS_O_NOATIME: 0;
121 int cfs_oflags2univ(int flags)
128 * XXX Liang: we don't need cfs_univ2oflags() now.
130 int cfs_univ2oflags(int flags)
135 EXPORT_SYMBOL(cfs_filp_open);
136 EXPORT_SYMBOL(cfs_user_write);
137 EXPORT_SYMBOL(cfs_oflags2univ);
138 EXPORT_SYMBOL(cfs_univ2oflags);