1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
/////////////////////////////////////////////////////////////////////////////////////////
/*FLAGS FROM KERNEL*/
//#define MS_RDONLY 1 /* Mount read-only */
//#define MS_NOSUID 2 /* Ignore suid and sgid bits */
//#define MS_NODEV 4 /* Disallow access to device special files */
//#define MS_NOEXEC 8 /* Disallow program execution */
//#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
//#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
//#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
//#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
//#define MS_NOATIME 1024 /* Do not update access times. */
//#define MS_NODIRATIME 2048 /* Do not update directory access times */
//#define MS_BIND 4096
//#define MS_MOVE 8192
//#define MS_REC 16384
//#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
// MS_VERBOSE is deprecated. */
//#define MS_SILENT 32768
//#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
//#define MS_UNBINDABLE (1<<17) /* change to unbindable */
//#define MS_PRIVATE (1<<18) /* change to private */
//#define MS_SLAVE (1<<19) /* change to slave */
//#define MS_SHARED (1<<20) /* change to shared */
//#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
//#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
//#define MS_I_VERSION (1<<23) /* Update inode I_version field */
//#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
//#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
typedef struct {
int f_output; //show statistics of pipe
int f_stopzero; //stop if 0 bytes in input
int f_nowriteout; // dont write to output
int f_graphmode; //show graph
} mount_params;
static mount_params g_params;
void helper(char *progname)
{
printf("Usage: %s [OPTS]\n\n"
"Version: 0.0.1 \n"
"\n"
, progname);
}
void sig_handler(int signo)
{
switch(signo)
{
case SIGINT:
//printf("Catch SIGINT Exit\n");
//if (g_params.f_output)
//{
// printf("Data in %d bytes Data out %d bytes",g_stats.cnt_in,g_stats.cnt_out);
//}
default:
printf("Unknown signal %d\n",signo);
}
exit(0);
}
int smount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
int main(int argc, char **argv)
{
int c;
printf("One big real mount\n");
if (signal(SIGINT,sig_handler) == SIG_ERR)
{
printf("cannot register signal handler\n");
exit(1);
}
//process arguments
while ((c = getopt(argc, argv, "osng")) != -1)
{
switch (c)
{
case 'v':
//g_params.f_output = 1;
break;
default:
helper(argv[0]);
exit(1);
}
}
return 0;
}
int smount(
const char *source,
const char *target,
const char *filesystemtype,
unsigned long mountflags,
const void *data)
{
return 0;
}
|