2
* Author: Colin King <colin.king@canonical.com>
4
* Copyright (C) 2012 Canonical, Ltd.
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27
#include <sys/types.h>
32
#define TEST_PASSED (0)
33
#define TEST_FAILED (1)
34
#define TEST_ERROR (2)
37
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/524919
39
* test that readlink() and lstat() size of a symlink are the same length
41
int main(int argc, char **argv)
51
fprintf(stderr, "Usage: filename\n");
55
if ((fd = open(argv[1], O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) {
56
fprintf(stderr, "cannot create %s : %s\n", argv[1],
62
fprintf(stderr, "close failed %s: %s\n", argv[1],
68
snprintf(link, sizeof(link), "%s-symlink", argv[1]);
69
if (symlink(argv[1], link) < 0) {
70
fprintf(stderr, "symlink failed %s: %s\n", argv[1],
76
n = readlink(link, buf, sizeof(buf));
78
fprintf(stderr, "readlink failed %s: %s\n", argv[1],
83
if (lstat(link, &statbuf) < 0) {
84
fprintf(stderr, "lstat failed %s: %s\n", argv[1],
90
/* Should be the same size */
91
if (statbuf.st_size != n)