4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details. A copy is
14 * included in the COPYING file that accompanied this code.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Copyright (c) 2013, Intel Corporation.
24 * lustre/tests/listxattr_size_check.c
26 * Author: Keith Mannthey <keith.mannthey@intel.com>
29 #include <sys/types.h>
30 #include <sys/xattr.h>
36 static void usage(char *prog)
38 printf("Usage: %s <pathname>\n", prog);
41 /* Test the listxattr return value when the buffer is small. */
42 int main(int argc, char *argv[])
45 ssize_t ret_buf, ret_null, error_s;
55 ret_null = listxattr(path, NULL, 0);
57 fprintf(stderr, "listxattr(%s, NULL, 0) failed "
58 "with %i: %s\n", path, errno,
64 /* LU-3403 llite: error of listxattr when buffer is small */
67 "listxattr(%s, NULL, 0) returned a sizes less than 2",
73 error_s = ret_null - 1;
74 buf = (char *)malloc(error_s);
76 fprintf(stderr, "malloc(%zi) failed with %i: %s\n",
77 error_s, errno, strerror(errno));
82 ret_buf = llistxattr(path, buf, error_s);
84 fprintf(stderr, "llistxattr(%s, %p, %zi) passed with %zi but "
85 "should have failed with -1\n", path, buf,