50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
+
+
+
+
|
int childcount;
} dir;
struct {
int executable;
off_t size;
char sha1[41];
} file;
struct {
off_t size;
char source[256];
} symlink;
} typeinfo;
};
struct appfs_sqlite3_query_cb_handle {
struct appfs_children *head;
int argc;
const char *fmt;
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
-
|
APPFS_DEBUG("Call to ::appfs::getpkgmanifest failed: %s", Tcl_GetStringResult(interp));
return;
}
return;
}
#define appfs_free_list_type(id, type) static void appfs_free_list_ ## id(type *head) { \
type *obj, *next; \
for (obj = head; obj; obj = next) { \
next = obj->_next; \
ckfree((void *) obj); \
} \
|
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
return(0);
}
if (strcmp(type, "directory") == 0) {
pathinfo->type = APPFS_PATHTYPE_DIRECTORY;
pathinfo->typeinfo.dir.childcount = 0;
return(0);
}
if (strcmp(type, "symlink") == 0) {
pathinfo->type = APPFS_PATHTYPE_SYMLINK;
pathinfo->typeinfo.dir.childcount = 0;
if (!source) {
source = ".BADLINK";
}
pathinfo->typeinfo.symlink.size = strlen(source);
snprintf(pathinfo->typeinfo.symlink.source, sizeof(pathinfo->typeinfo.symlink.source), "%s", source);
return(0);
}
return(0);
/* Until this is used, prevent the compiler from complaining */
source = source;
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
|
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
|
}
}
free(path_s);
return(0);
}
static int appfs_fuse_readlink(const char *path, char *buf, size_t size) {
struct appfs_pathinfo pathinfo;
int res = 0;
APPFS_DEBUG("Enter (path = %s, ...)", path);
pathinfo.type = APPFS_PATHTYPE_INVALID;
res = appfs_get_path_info(path, &pathinfo, NULL);
if (res != 0) {
return(res);
}
if (pathinfo.type != APPFS_PATHTYPE_SYMLINK) {
return(-EINVAL);
}
if ((strlen(pathinfo.typeinfo.symlink.source) + 1) > size) {
return(-ENAMETOOLONG);
}
memcpy(buf, pathinfo.typeinfo.symlink.source, strlen(pathinfo.typeinfo.symlink.source) + 1);
return(0);
}
static int appfs_fuse_getattr(const char *path, struct stat *stbuf) {
struct appfs_pathinfo pathinfo;
int res = 0;
APPFS_DEBUG("Enter (path = %s, ...)", path);
pathinfo.type = APPFS_PATHTYPE_INVALID;
res = appfs_get_path_info(path, &pathinfo, NULL);
if (res != 0) {
return(res);
}
memset(stbuf, 0, sizeof(struct stat));
stbuf->st_mtime = pathinfo.time;
stbuf->st_ctime = pathinfo.time;
stbuf->st_atime = pathinfo.time;
switch (pathinfo.type) {
if (pathinfo.type == APPFS_PATHTYPE_DIRECTORY) {
stbuf->st_mode = S_IFDIR | 0555;
stbuf->st_nlink = 2 + pathinfo.typeinfo.dir.childcount;
} else {
if (pathinfo.typeinfo.file.executable) {
stbuf->st_mode = S_IFREG | 0555;
} else {
stbuf->st_mode = S_IFREG | 0444;
}
case APPFS_PATHTYPE_DIRECTORY:
stbuf->st_mode = S_IFDIR | 0555;
stbuf->st_nlink = 2 + pathinfo.typeinfo.dir.childcount;
break;
case APPFS_PATHTYPE_FILE:
if (pathinfo.typeinfo.file.executable) {
stbuf->st_mode = S_IFREG | 0555;
} else {
stbuf->st_mode = S_IFREG | 0444;
}
stbuf->st_nlink = 1;
stbuf->st_size = pathinfo.typeinfo.file.size;
stbuf->st_nlink = 1;
stbuf->st_size = pathinfo.typeinfo.file.size;
break;
case APPFS_PATHTYPE_SYMLINK:
stbuf->st_mode = S_IFLNK | 0555;
stbuf->st_nlink = 1;
stbuf->st_size = pathinfo.typeinfo.symlink.size;
break;
case APPFS_PATHTYPE_INVALID:
res = -EIO;
break;
}
return res;
}
static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
struct appfs_pathinfo pathinfo;
|
809
810
811
812
813
814
815
816
817
818
819
820
821
822
|
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
|
+
|
return(read_ret);
}
static struct fuse_operations appfs_oper = {
.getattr = appfs_fuse_getattr,
.readdir = appfs_fuse_readdir,
.readlink = appfs_fuse_readlink,
.open = appfs_fuse_open,
.release = appfs_fuse_close,
.read = appfs_fuse_read
};
int main(int argc, char **argv) {
const char *cachedir = APPFS_CACHEDIR;
|