problem in adding an extra entry in a dir:fuse imlementation

Well the problem comes when i try to add an extra file into the existing filesystem mounted at some mountpoint containing a single file hello.
suppose i add a file say "TANVIR"(c it on d line next to line no:49) ,
it gives me abnormal results......
like 1)d file can't be opened
2)no file exists....

help me out if ne 1 has used fuse......:slight_smile:

00001 /*
00002 FUSE: Filesystem in Userspace
00003 Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
00004
00005 This program can be distributed under the terms of the GNU GPL.
00006 See the file COPYING.
00007 */
00008
00009 #include <fuse.h>
00010 #include <stdio.h>
00011 #include <string.h>
00012 #include <errno.h>
00013 #include <fcntl.h>
00014
00015 static const char *hello_str = "Hello World!\n";
00016 static const char *hello_path = "/hello";
00017
00018 static int hello_getattr(const char *path, struct stat *stbuf)
00019 {
00020 int res = 0;
00021
00022 memset(stbuf, 0, sizeof(struct stat));
00023 if(strcmp(path, "/") == 0) {
00024 stbuf->st_mode = S_IFDIR | 0755;
00025 stbuf->st_nlink = 2;
00026 }
00027 else if(strcmp(path, hello_path) == 0) {
00028 stbuf->st_mode = S_IFREG | 0444;
00029 stbuf->st_nlink = 1;
00030 stbuf->st_size = strlen(hello_str);
00031 }
0032 else if(strcmp(path,"TANVIR")==0){
stbuf->st_mode = S_IFREG | 0444;
stbuf->st_nlink = 1;
stbuf->st_size = 10;

           \{
           else

00033 res = -ENOENT;
00034
00035 return res;
00036 }
00037
00038 static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
00039 off_t offset, struct fuse_file_info *fi)
00040 {
00041 (void) offset;
00042 (void) fi;
00043
00044 if(strcmp(path, "/") != 0)
00045 return -ENOENT;
00046
00047 filler(buf, ".", NULL, 0);
00048 filler(buf, "..", NULL, 0);
00049 filler(buf, hello_path + 1, NULL, 0);
**** filler(buf,"TANVIR",NULL,0);//when i add dis statement
00050
00051 return 0;
00052 }
00053
00054 static int hello_open(const char path, struct fuse_file_info fi)
00055 {
00056 /
if(strcmp(path, hello_path) != 0)
00057 return -ENOENT;
00058
00059 if((fi->flags & 3) != O_RDONLY)
00060 return -EACCES;
/
00061
00062 return 0;
00063 }
00064
00065 static int hello_read(const char *path, char *buf, size_t size, off_t offset,
00066 struct fuse_file_info *fi)
00067 {
00068 size_t len;
00069 (void) fi;
00070 if(strcmp(path, hello_path) != 0)
00071 return -ENOENT;
00072
00073 len = strlen(hello_str);
00074 if (offset < len) {
00075 if (offset + size > len)
00076 size = len - offset;
00077 memcpy(buf, hello_str + offset, size);
00078 } else
00079 size = 0;
00080
00081 return size;
00082 }
00083
00084 static struct fuse_operations hello_oper = {
00085 .getattr = hello_getattr,
00086 .readdir = hello_readdir,
00087 .open = hello_open,
00088 .read = hello_read,
00089 };
00090
00091 int main(int argc, char *argv[])
00092 {
00093 return fuse_main(argc, argv, &hello_oper);
00094 }