1 #include "cachefsicache.h"
7 bool ICache::maybe_get_attr(WvString path
, struct fuse_attr
*attr
)
9 INode
*inode
= maybe_get_inode(path
);
12 return inode
->maybe_get_attr(attr
);
15 bool ICache::maybe_get_link(WvString path
, char *buf
, size_t size
)
17 INode
*inode
= maybe_get_inode(path
);
20 return inode
->maybe_get_link(buf
, size
);
23 bool ICache::maybe_get_children(WvString path
, WvFuseDirCb
&cb
)
25 INode
*inode
= maybe_get_inode(path
);
29 if (!inode
->can_get_children())
33 struct fuse_dirent fde
;
34 WvString
fullpath("%s/%s", cfg
["Meta Root"].get(), path
);
35 DIR *dp
= opendir(fullpath
);
40 while (dp
&& (de
= readdir(dp
)) != NULL
)
41 if (strcmp(de
->d_name
, ".") && strcmp(de
->d_name
, "..")
42 && strcmp(de
->d_name
, ".cachefsdirdata"))
44 strncpy(fde
.name
, de
->d_name
, NAME_MAX
);
45 fde
.namelen
= strlen(de
->d_name
);
46 fde
.type
= maybe_get_mode(WvString("%s/%s", path
, fde
.name
));
55 unsigned char ICache::maybe_get_mode(WvString path
)
57 if (INode
*inode
= maybe_get_inode(path
))
59 return inode
->get_mode();
65 void ICache::set_attr(WvStringParm path
, struct fuse_attr
*attr
)
67 INode
*inode
= maybe_get_inode(path
, IFTODT(attr
->mode
));
69 inode
->set_attr(attr
);
71 fprintf(stderr
, "Cache error updating attributes "
72 "on node '%s'\n", path
.cstr());
75 void ICache::set_link(WvStringParm path
, char *buf
)
77 INode
*inode
= maybe_get_inode(path
, 0);
81 fprintf(stderr
, "Cache error updating link "
82 "on node '%s'\n", path
.cstr());
85 void ICache::set_children(WvStringParm path
)
87 INode
*inode
= maybe_get_inode(path
, 0);
89 inode
->set_children();
91 fprintf(stderr
, "Cache error in set_children "
92 "on node '%s'\n", path
.cstr());
95 INode
*ICache::maybe_get_inode(WvStringParm path
, unsigned char mode
)
97 INode
*inode
= MyMRU::maybe_get(path
);
102 inode
= new INode(this);
103 if (inode
->init(path
, mode
))
105 MyMRU::add(path
, inode
);