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)
60 char *short_opts = "h", *name = argv[0];
61 static struct option long_opts[] = {
62 #define OPT_GETATTR -2
63 {"getattr", no_argument, NULL, OPT_GETATTR},
64 #define OPT_READPAGE -3
65 {"readpage", no_argument, NULL, OPT_READPAGE},
66 #define OPT_SETATTR -4
67 {"setattr", no_argument, NULL, OPT_SETATTR},
69 {"create", no_argument, NULL, OPT_CREATE},
71 {"open", no_argument, NULL, OPT_OPEN},
73 {"close", required_argument, NULL, OPT_CLOSE},
75 {"help", no_argument, NULL, OPT_HELP},
80 c = getopt_long(argc, argv, short_opts, long_opts, NULL);
87 cmd = IOC_REQUEST_GETATTR;
92 cmd = IOC_REQUEST_SETATTR;
97 cmd = IOC_REQUEST_READPAGE;
102 cmd = IOC_REQUEST_CREATE;
107 cmd = IOC_REQUEST_OPEN;
112 cmd = IOC_REQUEST_CLOSE;
114 arg = strtoul(optarg, NULL, 0);
124 fd = open("/dev/request", O_RDONLY);
126 fprintf(stderr, "error opening /dev/request: %s\n",
131 fprintf(stderr, "Executing %s test (arg=%lu)...\n", name, arg);
132 if (cmd == IOC_REQUEST_OPEN) {
133 rc = ioctl(fd, cmd, &arg);
134 printf("%lu\n", arg);
136 rc = ioctl(fd, cmd, arg);
137 fprintf(stderr, "result code: %d\n", rc);