Reputation: 1
Im trying to have fuse create files when I mount the system using the init function. However whenever I mount my system the process never ends. Then i cant unmount it afterwards. How do i fix this.
void file_init(struct fuse_conn_info *conn){
FILE *fp;
fp=fopen("/data1/fuse/file.txt","w+");
fclose(fp);
}
Thats the code im using. I need to create multiple files but I cant even get this 1 file to work.
Upvotes: 0
Views: 1077
Reputation: 41017
Check the return of fopen
if you want to know why it fails:
fp = fopen("/data1/fuse/file.txt", "w+");
if (fp == NULL) {
perror("fopen");
exit(EXIT_FAILURE);
}
fclose(fp);
If data1
is in the same directory (not in the root path), change
fp=fopen("/data1/fuse/file.txt","w+");
to
fp=fopen("data1/fuse/file.txt","w+"); /* remove the first backslash */
Upvotes: 1