1 #define _MINIX_SYSTEM 1
3 #include <sys/svrctl.h>
12 static void usage(void);
19 static char *bin_name
;
21 int main (int argc
, char *argv
[])
24 endpoint_t proc_e
= NONE
;
25 struct sysgetenv sysgetenv
;
26 char *to_whom
, *operation
, *what
, *value
;
30 if (argc
< 4 || argc
> 5) usage();
32 fprintf(stderr
, "You have to be root to run this utility\n");
36 /* Make some parameters lower case to ease comparing */
40 for (i
= 0; i
< strlen(to_whom
); ++i
) to_whom
[i
] = tolower(to_whom
[i
]);
41 for (i
= 0; i
< strlen(operation
); ++i
) operation
[i
] = tolower(operation
[i
]);
42 for (i
= 0; i
< strlen(what
); ++i
) what
[i
] = tolower(what
[i
]);
44 if (!strncmp(to_whom
, VFS
, strlen(VFS
)+1)) proc_e
= VFS_PROC_NR
;
45 else if (!strncmp(to_whom
, PM
, strlen(PM
)+1)) proc_e
= PM_PROC_NR
;
49 sysgetenv
.keylen
= strlen(what
) + 1;
51 if (!strncmp(operation
, SET
, strlen(SET
)+1)) {
52 if (argc
!= 5) usage();
54 sysgetenv
.val
= value
;
55 sysgetenv
.vallen
= strlen(value
) + 1;
57 if (proc_e
== VFS_PROC_NR
)
59 else if (proc_e
== PM_PROC_NR
)
64 if (svrctl(param
, &sysgetenv
) != 0) {
66 fprintf(stderr
, "invalid parameter: %s\n", what
);
67 else if (errno
== EINVAL
)
68 fprintf(stderr
, "invalid value: %s\n", value
);
74 } else if (!strncmp(operation
, GET
, strlen(GET
)+1)) {
75 char get_param_buffer
[4096];
77 memset(get_param_buffer
, '\0', sizeof(get_param_buffer
));
78 sysgetenv
.val
= get_param_buffer
;
79 sysgetenv
.vallen
= sizeof(get_param_buffer
) - 1;
81 if (proc_e
== VFS_PROC_NR
)
83 else if (proc_e
== PM_PROC_NR
)
88 if (svrctl(param
, &sysgetenv
) != 0) {
90 fprintf(stderr
, "invalid parameter: %s\n", what
);
95 if (sysgetenv
.vallen
> 0) {
96 get_param_buffer
[sysgetenv
.vallen
] = '\0';
97 printf("%s\n", get_param_buffer
);
100 return(EXIT_SUCCESS
);
104 return(EXIT_FAILURE
);
109 fprintf(stderr
, "Usage:\n");
110 fprintf(stderr
, " %s <vfs|pm> set <request> <value>\n", bin_name
);
111 fprintf(stderr
, " %s <vfs|pm> get <request>\n", bin_name
);