int main(int argc, char *argv[]) { char *name; /* size must be provided, and an optional logring name */ if (argc != 2 && argc != 3) { fprintf(stderr, "usage: %s <logring-size> [logring-name]\n", argv[0]); exit(1); } name = (argc == 3 ? argv[2] : "/dev/logring"); /* convert the arg to an int and alloc memory for the logring */ if ((logring_size = atoi(argv[1])) <= 0) { fprintf(stderr, "invalid logring size; it must be >0\n"); exit(1); } if ((logring_data = (char *) malloc(sizeof(char) * logring_size)) == NULL) { fprintf(stderr, "couldn't allocate %d bytes!\n", logring_size); exit(1); } /* register the fusd device */ fusd_simple_register(name, "misc", "logring", 0666, NULL, open: logring_open, close: logring_close, read: logring_read, write: logring_write, poll_diff: logring_polldiff); printf("calling fusd_run; reads from /dev/logring will now block\n" "until someone writes to /dev/logring...\n"); fusd_run(); return 0; }
int main(int argc, char *argv[]) { if (fusd_register("/dev/echo", "misc", "echo", 0666, NULL, &echo_fops) < 0) { perror("register of /dev/echo failed"); exit(1); } fprintf(stderr, "calling fusd_run...\n"); fusd_run(); return 0; }