1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.sf.net/projects/lustre/
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include <sys/ioctl.h>
36 #include <linux/lustre_mds.h>
38 static void usage(char *argv0, int status)
41 "Usage: %s [OPTION...]\n\
43 --getattr <directory>\n\
44 --setattr <directory>\n\
45 --readpage <directory>\n\
47 --close <directory handle (returned by open)>\n\
48 --create <new name>\n", argv0);
53 int main(int argc, char **argv)
55 int fd, rc, c, cmd = 0;
57 char *short_opts = "h", *name = argv[0];
58 static struct option long_opts[] = {
59 #define OPT_GETATTR -2
60 {"getattr", no_argument, NULL, OPT_GETATTR},
61 #define OPT_READPAGE -3
62 {"readpage", no_argument, NULL, OPT_READPAGE},
63 #define OPT_SETATTR -4
64 {"setattr", no_argument, NULL, OPT_SETATTR},
66 {"create", no_argument, NULL, OPT_CREATE},
68 {"open", no_argument, NULL, OPT_OPEN},
70 {"close", required_argument, NULL, OPT_CLOSE},
72 {"help", no_argument, NULL, OPT_HELP},
77 c = getopt_long(argc, argv, short_opts, long_opts, NULL);
84 cmd = IOC_REQUEST_GETATTR;
89 cmd = IOC_REQUEST_SETATTR;
94 cmd = IOC_REQUEST_READPAGE;
99 cmd = IOC_REQUEST_CREATE;
104 cmd = IOC_REQUEST_OPEN;
109 cmd = IOC_REQUEST_CLOSE;
111 arg = strtoul(optarg, NULL, 0);
121 fd = open("/dev/request", O_RDONLY);
123 fprintf(stderr, "error opening /dev/request: %s\n",
128 fprintf(stderr, "Executing %s test (arg=%lu)...\n", name, arg);
129 if (cmd == IOC_REQUEST_OPEN) {
130 rc = ioctl(fd, cmd, &arg);
131 printf("%lu\n", arg);
133 rc = ioctl(fd, cmd, arg);
134 fprintf(stderr, "result code: %d\n", rc);