pull master
[hh.org.git] / lab / modules / labmount.c
blob4fe18dfc0549c5654666b271a4f867c6d073f478
1 /*
2 * labmount.c
3 * A mount module for LAB
5 * Copyright (c) 2003 Joshua Wise
6 */
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/syscalls.h>
12 #include <linux/lab/lab.h>
13 #include <linux/lab/commands.h>
15 void lab_cmd_mount(int argc,const char** argv);
16 void lab_cmd_umount(int argc,const char** argv);
18 int labmount_init(void)
20 lab_addcommand("mount", lab_cmd_mount, "Allows you to mount a filesystem");
21 lab_addcommand("umount", lab_cmd_umount, "Allows you to unmount a filesystem");
22 return 0;
25 void labmount_cleanup(void)
27 lab_delcommand("mount");
28 lab_delcommand("umount");
32 void lab_cmd_mount(int argc,const char** argv)
34 const char* devname;
35 const char* path;
36 const char* fstype;
37 int retval;
39 if (argc < 3 || argc > 4) {
40 lab_puts("mount: syntax: mount devname path [fstype]\r\n"
41 "mount: where: devname is a device name including the /dev\r\n"
42 "mount: path is a path to mount at including the leading /\r\n"
43 "mount: and fstype is an optional filesystem type (default is jffs2)\r\n");
44 return;
47 devname = argv[1];
48 path = argv[2];
49 if (argc == 4)
50 fstype = argv[3];
51 else
52 fstype = "jffs2";
54 if ((retval = sys_mount((char*)devname, (char*)path, (char*)fstype, 0, "")) < 0) {
55 lab_printf("lab: mount -t %s %s %s failed with errno %d\r\n",
56 fstype, devname, path, retval);
57 globfail++;
61 void lab_cmd_umount(int argc,const char** argv)
63 int retval;
65 if (argc != 2) {
66 lab_puts("umount: syntax: umount path\r\n");
67 return;
70 if ((retval = sys_oldumount((char*)argv[1])) < 0) {
71 lab_printf("lab: umount %s failed with errno %d\n", argv[1], retval);
72 globfail++;
76 MODULE_AUTHOR("Joshua Wise");
77 MODULE_DESCRIPTION("LAB mount Module");
78 MODULE_LICENSE("GPL");
79 module_init(labmount_init);
80 module_exit(labmount_cleanup);