Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <string.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <fuse.h>
- #include "fuu_walk.h"
- #include "jsmnload.h"
- #define _JSMN_TOKEN_SIZE_ 256
- #define _JSMN_BUFFER_SIZE_ 4096
- #define MYFS_OPT(t, p, v) { t, offsetof(struct myfs_config, p), v }
- struct myfs_config {
- char *mystring;
- } conf;
- static struct fuse_opt myfs_opts[] = {
- MYFS_OPT("-c %s", mystring, 1),
- //FUSE_OPT_KEY("-c", 1), FUSE_OPT_KEY как я понял используется для перегрузки уже заложенных библиотекой опций, но пробовал и его подпихивать - ни в какую.
- FUSE_OPT_END
- };
- jsmntok_t t[_JSMN_TOKEN_SIZE_];
- char buf[_JSMN_BUFFER_SIZE_];
- #if 0
- = ""
- "{"root": ["
- "{"path":"/", "mode":"drw-------"},"
- "{"path":"/12ABC345DE67", "mode":"drw-------"},"
- "{"path":"/12ABC345DE67/_XQ01", "mode":"-rw-------"},"
- "{"path":"/12ABC345DE67/_XQ02", "mode":"-rw-------"},"
- "{"path":"/12ABC345DE78", "mode":"drw-------"},"
- "{"path":"/12ABC345DE89", "mode":"drw-------"}"
- "]}";
- #endif
- static int myfs_opt_proc(void *data, const char *arg, int key, struct fuse_args *outargs)
- {
- struct myfs_config *ptr = (struct myfs_config *)data;
- FILE *conf;
- int rc = 0;
- //Хочу проверить сколько раз я зашел в эту функцию принтфом.
- printf("arg = %st string %st key = %in", arg, ptr->mystring, key);
- switch (key) {
- case 1:
- conf = fopen(ptr->mystring, "r");
- rc = read(fileno(conf), buf, _JSMN_BUFFER_SIZE_);
- if ( jsmnload(buf, t, _JSMN_TOKEN_SIZE_, fuu_mkfstree) < 0 ) {
- printf("Error load configurationn");
- exit(-1);
- }
- }
- return 1;
- }
- int main(int argc, char *argv[])
- {
- struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
- memset(&conf, 0, sizeof(conf));
- fuse_opt_parse(&args, &conf, myfs_opts, myfs_opt_proc);
- return fuu_main(args.argc, args.argv);
- }
- ./appendix/fuu /mnt/cdrom/ -c /mnt/fs.json
- arg = /mnt/cdrom/ string (null) key = -2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement