1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Light user test program
6 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 #include <sys/types.h>
35 #include <sys/queue.h>
36 #include <sys/statvfs.h>
42 int do_stat(const char *name)
46 if (lstat(name, &stat)) {
47 perror("failed to stat: ");
50 printf("******* stat '%s' ********\n", name);
51 printf("ino:\t\t%lu\n",stat.st_ino);
52 printf("mode:\t\t%o\n",stat.st_mode);
53 printf("nlink:\t\t%d\n",stat.st_nlink);
54 printf("uid/gid:\t%d/%d\n", stat.st_uid, stat.st_gid);
55 printf("size:\t\t%ld\n", stat.st_size);
56 printf("blksize:\t%ld\n", stat.st_blksize);
57 printf("block count:\t%ld\n", stat.st_blocks);
58 printf("atime:\t\t%lu\n",stat.st_atime);
59 printf("mtime:\t\t%lu\n",stat.st_mtime);
60 printf("ctime:\t\t%lu\n",stat.st_ctime);
61 printf("******* end stat ********\n");
66 * Get stats of file and file system.
68 * Usage: test_stats [-a] [-r <root-path>] [-m <root-driver>] [<path> ...]
71 extern int lllib_init(char *arg);
73 char *root_driver = "llite";
74 char *root_path = "/";
76 struct mount root_mount;
78 extern int portal_debug;
79 extern int portal_subsystem_debug;
81 char* files[] = {"/dir1", "/dir1/file1", "/dir1/file2", "/dir1/dir2", "/dir1/dir2/file3"};
84 main(int argc, char * const argv[])
87 int rc, err, i, fd, written, readed;
88 char pgbuf[4096], readbuf[4096];
91 if (_sysio_init() != 0) {
95 err = lllib_init(argv[1]);
97 perror("init llite driver");
101 err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL);
108 for (i=0; i< sizeof(files)/sizeof(char*); i++) {
109 printf("******** stat %s *********\n", files[i]);
110 /* XXX ugly, only for testing */
111 err = fixme_lstat(files[i], &statbuf);
114 printf("******** end stat %s: %d*********\n", files[i], err);
119 portal_subsystem_debug = 0;
122 fd = open("/newfile01", O_RDWR|O_CREAT|O_TRUNC, 00664);
123 printf("***************** open return %d ****************\n", fd);
125 printf("***************** begin write pages ****************\n");
126 for (i = 0; i < npages; i++ ) {
127 memset(pgbuf, ('A'+ i%10), 4096);
128 written = write(fd, pgbuf, 4096);
129 printf(">>> page %d: %d bytes written\n", i, written);
132 printf("***************** begin read pages ****************\n");
133 lseek(fd, 0, SEEK_SET);
135 for (i = 0; i < npages; i++ ) {
136 memset(readbuf, '8', 4096);
137 readed = read(fd, readbuf, 4096);
139 printf("<<< page %d: %d bytes (%s)\n", i, readed, readbuf);
145 //rc = chown("/newfile01", 10, 20);
146 rc = chmod("/newfile01", 0777);
147 printf("-------------- chmod return %d -----------\n", rc);
148 do_stat("/newfile01");
151 printf("sysio is about shutdown\n");
157 printf("complete successfully\n");