xref: /netbsd-src/tests/fs/psshfs/h_have_puffs.c (revision 7f396ca714374c7111f13677addafb831ed6d544)
1*7f396ca7Spooka /* $NetBSD: h_have_puffs.c,v 1.1 2010/07/06 14:06:22 pooka Exp $ */
2*7f396ca7Spooka /*
3*7f396ca7Spooka  * Copyright (c) 2007 The NetBSD Foundation, Inc.
4*7f396ca7Spooka  * All rights reserved.
5*7f396ca7Spooka  *
6*7f396ca7Spooka  * Redistribution and use in source and binary forms, with or without
7*7f396ca7Spooka  * modification, are permitted provided that the following conditions
8*7f396ca7Spooka  * are met:
9*7f396ca7Spooka  * 1. Redistributions of source code must retain the above copyright
10*7f396ca7Spooka  *    notice, this list of conditions and the following disclaimer.
11*7f396ca7Spooka  * 2. Redistributions in binary form must reproduce the above copyright
12*7f396ca7Spooka  *    notice, this list of conditions and the following disclaimer in the
13*7f396ca7Spooka  *    documentation and/or other materials provided with the distribution.
14*7f396ca7Spooka  *
15*7f396ca7Spooka  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16*7f396ca7Spooka  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17*7f396ca7Spooka  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18*7f396ca7Spooka  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19*7f396ca7Spooka  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20*7f396ca7Spooka  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21*7f396ca7Spooka  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22*7f396ca7Spooka  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23*7f396ca7Spooka  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24*7f396ca7Spooka  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*7f396ca7Spooka  * POSSIBILITY OF SUCH DAMAGE.
26*7f396ca7Spooka  */
27*7f396ca7Spooka 
28*7f396ca7Spooka #include <errno.h>
29*7f396ca7Spooka #include <fcntl.h>
30*7f396ca7Spooka #include <stdio.h>
31*7f396ca7Spooka #include <stdlib.h>
32*7f396ca7Spooka #include <unistd.h>
33*7f396ca7Spooka 
34*7f396ca7Spooka int
main(void)35*7f396ca7Spooka main(void)
36*7f396ca7Spooka {
37*7f396ca7Spooka 	int exitcode, fd;
38*7f396ca7Spooka 
39*7f396ca7Spooka 	fd = open("/dev/puffs", O_RDWR);
40*7f396ca7Spooka 	if (fd != -1) {
41*7f396ca7Spooka 		printf("yes\n");
42*7f396ca7Spooka 		close(fd);
43*7f396ca7Spooka 		exitcode = EXIT_SUCCESS;
44*7f396ca7Spooka 	} else {
45*7f396ca7Spooka 		if (errno == ENXIO) {
46*7f396ca7Spooka 			printf("enxio\n");
47*7f396ca7Spooka 			exitcode = EXIT_SUCCESS;
48*7f396ca7Spooka 		} else if (errno == EACCES) {
49*7f396ca7Spooka 			printf("eacces\n");
50*7f396ca7Spooka 			exitcode = EXIT_SUCCESS;
51*7f396ca7Spooka 		} else {
52*7f396ca7Spooka 			printf("failed\n");
53*7f396ca7Spooka 			exitcode = EXIT_FAILURE;
54*7f396ca7Spooka 		}
55*7f396ca7Spooka 	}
56*7f396ca7Spooka 
57*7f396ca7Spooka 	return exitcode;
58*7f396ca7Spooka }
59