+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <asm/statfs.h>
-#include <unistd.h>
-
-#define OBD_IOC_CREATE _IOR('f', 3, long)
-#define OBD_IOC_SETUP _IOW('f', 4, long)
-#define OBD_IOC_SYNC _IOR('f', 16, long)
-#define OBD_IOC_DESTROY _IOW('f', 6, long)
-#define OBD_IOC_STATFS _IORW('f', 15, long)
-
-#define LOOP_DEVICE "/dev/loop0"
-#define OBD_DEVICE "/dev/obd"
-
-int main (int argc, char * argv[])
-{
- int fd, rc, err = -1;
- struct stat stat_buf;
- struct statfs stfs;
-
-
- if (argc < 2) {
- printf("syntax: %s command [argument]\n", argv[0]);
- printf("Where command is one of \"setup\", \"create\", \"destroy\", or \"sync\".\n");
- exit(1);
- }
- if (stat(LOOP_DEVICE, &stat_buf)) {
- printf("Couldn't stat(" LOOP_DEVICE ").\n");
- exit(1);
- }
- printf("Device: %u\n", (unsigned int) stat_buf.st_rdev);
-
- fd = open (OBD_DEVICE, O_RDONLY);
- if (fd == -1) {
- printf("Couldn't open " OBD_DEVICE ".\n");
- exit(1);
- }
-
- if (!strcmp(argv[1], "setup")) {
- rc = ioctl(fd, OBD_IOC_SETUP, &stat_buf.st_rdev);
- fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
- } else if (!strcmp(argv[1], "create")) {
- int iter, i;
-
- if (argc < 3) {
- printf("create requires a nonzero argument.\n");
- exit(1);
- }
-
- iter = atoi(argv[2]);
- if (iter < 1) {
- printf("create requires a nonzero argument.\n");
- exit(1);
- }
- printf("creating %d objects...\n", iter);
-
- for (i = 0; i < iter; i++) {
- if ((rc = ioctl(fd, OBD_IOC_CREATE, &err))) {
- fprintf(stderr, "Error; aborting.\n");
- break;
- }
- if ((rc = ioctl(fd, OBD_IOC_DESTROY, &err))) {
- fprintf(stderr, "Error; aborting.\n");
- break;
- }
- }
- fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
- rc, errno, err);
- } else if (!strcmp(argv[1], "sync")) {
- rc = ioctl(fd, OBD_IOC_SYNC, &err);
- fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
- rc, errno, err);
- } else if (!strcmp(argv[1], "destroy")) {
- int ino;
-
- if (argc < 3) {
- printf("destroy requires a nonzero inode number.\n");
- exit(1);
- }
-
- ino = atoi(argv[2]);
- if (ino < 1) {
- printf("destroy requires a nonzero inode number.\n");
- exit(1);
- }
-
- rc = ioctl(fd, OBD_IOC_DESTROY, &ino);
- fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
- } else {
- printf("Invalid command, run with no arguments for help.\n");
- }
- close(fd);
-
- return 0;
-}
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-/* Beware when setting FSROOT that I've not made any attempts to avoid buffer
- * overruns below--this is a test program, it's a static buffer. */
-#define FSROOT "/mnt"
-#define OBD_ITERATIONS 10000
-
-int main (int argc, char * argv[])
-{
- int fd, rc, err = -1;
- struct stat stat_buf;
-
- if (argc < 2) {
- printf("syntax: %s command\n", argv[0]);
- printf("Where command is one of \"setup\" or \"create\".\n");
- exit(1);
- }
-
- if (!strcmp(argv[1], "setup")) {
- printf("This is silly.\n");
- } else if (!strcmp(argv[1], "create")) {
- int i, iter;
-
- if (argc < 3) {
- printf("create requires a nonzero argument.\n");
- exit(1);
- }
-
- iter = atoi(argv[2]);
-
- if (iter < 1) {
- printf("create requires a nonzero argument.\n");
- exit(1);
- }
- printf("creating %d files...\n", iter);
-
- for (i = 0; i < iter; i++) {
- fd = creat(FSROOT "/foo123", S_IRWXU);
- close(fd);
- unlink(FSROOT "/foo123");
- }
- } else {
- printf("Invalid command, run with no arguments for help.\n");
- }
-
- return 0;
-}