xref: /netbsd-src/tests/lib/libc/ssp/h_readlink.c (revision 575e75ffe48cfb5430348fc472fc4fbe32b5ae4f)
1*575e75ffSpgoyette /* $NetBSD: h_readlink.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
2*575e75ffSpgoyette 
3*575e75ffSpgoyette /*
4*575e75ffSpgoyette  * Copyright (c) 2008 The NetBSD Foundation, Inc.
5*575e75ffSpgoyette  * All rights reserved.
6*575e75ffSpgoyette  *
7*575e75ffSpgoyette  * Redistribution and use in source and binary forms, with or without
8*575e75ffSpgoyette  * modification, are permitted provided that the following conditions
9*575e75ffSpgoyette  * are met:
10*575e75ffSpgoyette  * 1. Redistributions of source code must retain the above copyright
11*575e75ffSpgoyette  *    notice, this list of conditions and the following disclaimer.
12*575e75ffSpgoyette  * 2. Redistributions in binary form must reproduce the above copyright
13*575e75ffSpgoyette  *    notice, this list of conditions and the following disclaimer in the
14*575e75ffSpgoyette  *    documentation and/or other materials provided with the distribution.
15*575e75ffSpgoyette  *
16*575e75ffSpgoyette  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17*575e75ffSpgoyette  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18*575e75ffSpgoyette  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19*575e75ffSpgoyette  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20*575e75ffSpgoyette  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*575e75ffSpgoyette  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*575e75ffSpgoyette  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*575e75ffSpgoyette  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*575e75ffSpgoyette  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*575e75ffSpgoyette  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26*575e75ffSpgoyette  * POSSIBILITY OF SUCH DAMAGE.
27*575e75ffSpgoyette  */
28*575e75ffSpgoyette 
29*575e75ffSpgoyette #include <sys/cdefs.h>
30*575e75ffSpgoyette __COPYRIGHT("@(#) Copyright (c) 2008\
31*575e75ffSpgoyette  The NetBSD Foundation, inc. All rights reserved.");
32*575e75ffSpgoyette __RCSID("$NetBSD: h_readlink.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
33*575e75ffSpgoyette 
34*575e75ffSpgoyette #include <sys/param.h>
35*575e75ffSpgoyette #include <stdio.h>
36*575e75ffSpgoyette #include <unistd.h>
37*575e75ffSpgoyette #include <stdlib.h>
38*575e75ffSpgoyette 
39*575e75ffSpgoyette int
main(int argc,char * argv[])40*575e75ffSpgoyette main(int argc, char *argv[])
41*575e75ffSpgoyette {
42*575e75ffSpgoyette 	char b[MAXPATHLEN];
43*575e75ffSpgoyette 	size_t len = atoi(argv[1]);
44*575e75ffSpgoyette 	(void)readlink("/", b, len);
45*575e75ffSpgoyette 	(void)printf("%s\n", b);
46*575e75ffSpgoyette 	return 0;
47*575e75ffSpgoyette }
48