xref: /netbsd-src/sys/lib/libsa/nullfs.c (revision 303a695e1bf470d4c2d8363797ec946988e615f1)
1*303a695eSchristos /*	$NetBSD: nullfs.c,v 1.12 2014/03/20 03:13:18 christos Exp $	*/
2b7b97847Sleo 
3b7b97847Sleo /*-
4b7b97847Sleo  * Copyright (c) 1993
5b7b97847Sleo  *	The Regents of the University of California.  All rights reserved.
6b7b97847Sleo  *
7b7b97847Sleo  * This code is derived from software contributed to Berkeley by
8b7b97847Sleo  * The Mach Operating System project at Carnegie-Mellon University.
9b7b97847Sleo  *
10b7b97847Sleo  * Redistribution and use in source and binary forms, with or without
11b7b97847Sleo  * modification, are permitted provided that the following conditions
12b7b97847Sleo  * are met:
13b7b97847Sleo  * 1. Redistributions of source code must retain the above copyright
14b7b97847Sleo  *    notice, this list of conditions and the following disclaimer.
15b7b97847Sleo  * 2. Redistributions in binary form must reproduce the above copyright
16b7b97847Sleo  *    notice, this list of conditions and the following disclaimer in the
17b7b97847Sleo  *    documentation and/or other materials provided with the distribution.
18aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
19b7b97847Sleo  *    may be used to endorse or promote products derived from this software
20b7b97847Sleo  *    without specific prior written permission.
21b7b97847Sleo  *
22b7b97847Sleo  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23b7b97847Sleo  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24b7b97847Sleo  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25b7b97847Sleo  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26b7b97847Sleo  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27b7b97847Sleo  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28b7b97847Sleo  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29b7b97847Sleo  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30b7b97847Sleo  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31b7b97847Sleo  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32b7b97847Sleo  * SUCH DAMAGE.
33b7b97847Sleo  *
34b7b97847Sleo  *	@(#)open.c	8.1 (Berkeley) 6/11/93
35b7b97847Sleo  *
36b7b97847Sleo  *
37b7b97847Sleo  * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University
38b7b97847Sleo  * All Rights Reserved.
39b7b97847Sleo  *
40b7b97847Sleo  * Author: Alessandro Forin
41b7b97847Sleo  *
42b7b97847Sleo  * Permission to use, copy, modify and distribute this software and its
43b7b97847Sleo  * documentation is hereby granted, provided that both the copyright
44b7b97847Sleo  * notice and this permission notice appear in all copies of the
45b7b97847Sleo  * software, derivative works or modified versions, and any portions
46b7b97847Sleo  * thereof, and that both notices appear in supporting documentation.
47b7b97847Sleo  *
48b7b97847Sleo  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
49b7b97847Sleo  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
50b7b97847Sleo  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
51b7b97847Sleo  *
52b7b97847Sleo  * Carnegie Mellon requests users of this software to return to
53b7b97847Sleo  *
54b7b97847Sleo  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
55b7b97847Sleo  *  School of Computer Science
56b7b97847Sleo  *  Carnegie Mellon University
57b7b97847Sleo  *  Pittsburgh PA 15213-3890
58b7b97847Sleo  *
59b7b97847Sleo  * any improvements or extensions that they make and grant Carnegie the
60b7b97847Sleo  * rights to redistribute these changes.
61b7b97847Sleo  */
62b7b97847Sleo 
63b7b97847Sleo #include "stand.h"
64b7b97847Sleo 
65b7b97847Sleo /*
66b7b97847Sleo  * Null filesystem
67b7b97847Sleo  */
68a20462dcSbjh21 
69c97378d0Sjoerg __compactcall int
null_open(const char * path,struct open_file * f)708453fb00Sdsl null_open(const char *path, struct open_file *f)
71b7b97847Sleo {
7243079a57Sbjh21 
73cff85b34Sdsl 	return EIO;
74b7b97847Sleo }
75b7b97847Sleo 
76a20462dcSbjh21 #ifndef LIBSA_NO_FS_CLOSE
77c97378d0Sjoerg __compactcall int
null_close(struct open_file * f)7843079a57Sbjh21 null_close(struct open_file *f)
79b7b97847Sleo {
8043079a57Sbjh21 
81b7b97847Sleo 	return 0;
82b7b97847Sleo }
83a20462dcSbjh21 #endif
84b7b97847Sleo 
85c97378d0Sjoerg __compactcall int
null_read(struct open_file * f,void * buf,size_t size,size_t * resid)8643079a57Sbjh21 null_read(struct open_file *f, void *buf, size_t size, size_t *resid)
87b7b97847Sleo {
8843079a57Sbjh21 
89cff85b34Sdsl 	return EIO;
90b7b97847Sleo }
91b7b97847Sleo 
92a20462dcSbjh21 #ifndef LIBSA_NO_FS_WRITE
93c97378d0Sjoerg __compactcall int
null_write(struct open_file * f,void * buf,size_t size,size_t * resid)9443079a57Sbjh21 null_write(struct open_file *f, void *buf, size_t size, size_t *resid)
95b7b97847Sleo {
9643079a57Sbjh21 
97cff85b34Sdsl 	return EIO;
98b7b97847Sleo }
99a20462dcSbjh21 #endif
100b7b97847Sleo 
101a20462dcSbjh21 #ifndef LIBSA_NO_FS_SEEK
102c97378d0Sjoerg __compactcall off_t
null_seek(struct open_file * f,off_t offset,int where)10343079a57Sbjh21 null_seek(struct open_file *f, off_t offset, int where)
104b7b97847Sleo {
10543079a57Sbjh21 
106cff85b34Sdsl 	return (off_t)-1;
107b7b97847Sleo }
108a20462dcSbjh21 #endif
109b7b97847Sleo 
110c97378d0Sjoerg __compactcall int
null_stat(struct open_file * f,struct stat * sb)11143079a57Sbjh21 null_stat(struct open_file *f, struct stat *sb)
112b7b97847Sleo {
11343079a57Sbjh21 
114cff85b34Sdsl 	return EIO;
115b7b97847Sleo }
116c2e8ce64Stsutsui 
117c2e8ce64Stsutsui #if defined(LIBSA_ENABLE_LS_OP)
118*303a695eSchristos #include "ls.h"
119c2e8ce64Stsutsui __compactcall void
null_ls(struct open_file * f,const char * pattern)120c2e8ce64Stsutsui null_ls(struct open_file *f, const char *pattern)
121c2e8ce64Stsutsui {
122*303a695eSchristos 	lsunsup("nullfs");
123c2e8ce64Stsutsui }
124c2e8ce64Stsutsui #endif
125