︙ | | | ︙ | |
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
/* Get information about a path, and optionally list children */
static int appfs_get_path_info(const char *path, struct appfs_pathinfo *pathinfo) {
Tcl_Interp *interp;
Tcl_Obj *attrs_dict, *attr_value;
const char *attr_value_str;
Tcl_WideInt attr_value_wide;
int attr_value_int;
static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL;
int tcl_ret;
interp = appfs_TclInterp();
if (interp == NULL) {
return(-EIO);
}
|
|
|
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
/* Get information about a path, and optionally list children */
static int appfs_get_path_info(const char *path, struct appfs_pathinfo *pathinfo) {
Tcl_Interp *interp;
Tcl_Obj *attrs_dict, *attr_value;
const char *attr_value_str;
Tcl_WideInt attr_value_wide;
int attr_value_int;
static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL, *attr_key_packaged = NULL;
int tcl_ret;
interp = appfs_TclInterp();
if (interp == NULL) {
return(-EIO);
}
|
︙ | | | ︙ | |
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
if (attr_key_type == NULL) {
attr_key_type = Tcl_NewStringObj("type", -1);
attr_key_perms = Tcl_NewStringObj("perms", -1);
attr_key_size = Tcl_NewStringObj("size", -1);
attr_key_time = Tcl_NewStringObj("time", -1);
attr_key_source = Tcl_NewStringObj("source", -1);
attr_key_childcount = Tcl_NewStringObj("childcount", -1);
}
attrs_dict = Tcl_GetObjResult(interp);
tcl_ret = Tcl_DictObjGet(interp, attrs_dict, attr_key_type, &attr_value);
if (tcl_ret != TCL_OK) {
APPFS_DEBUG("[dict get \"type\"] failed");
APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
|
>
|
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
if (attr_key_type == NULL) {
attr_key_type = Tcl_NewStringObj("type", -1);
attr_key_perms = Tcl_NewStringObj("perms", -1);
attr_key_size = Tcl_NewStringObj("size", -1);
attr_key_time = Tcl_NewStringObj("time", -1);
attr_key_source = Tcl_NewStringObj("source", -1);
attr_key_childcount = Tcl_NewStringObj("childcount", -1);
attr_key_packaged = Tcl_NewStringObj("packaged", -1);
}
attrs_dict = Tcl_GetObjResult(interp);
tcl_ret = Tcl_DictObjGet(interp, attrs_dict, attr_key_type, &attr_value);
if (tcl_ret != TCL_OK) {
APPFS_DEBUG("[dict get \"type\"] failed");
APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
|
︙ | | | ︙ | |
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
memcpy(pathinfo->typeinfo.symlink.source, attr_value_str, attr_value_int);
}
}
break;
default:
return(-EIO);
}
Tcl_DictObjGet(interp, attrs_dict, attr_key_time, &attr_value);
if (attr_value != NULL) {
tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
if (tcl_ret == TCL_OK) {
pathinfo->time = attr_value_wide;
}
|
>
>
>
>
>
|
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
memcpy(pathinfo->typeinfo.symlink.source, attr_value_str, attr_value_int);
}
}
break;
default:
return(-EIO);
}
Tcl_DictObjGet(interp, attrs_dict, attr_key_packaged, &attr_value);
if (attr_value != NULL) {
pathinfo->packaged = 1;
}
Tcl_DictObjGet(interp, attrs_dict, attr_key_time, &attr_value);
if (attr_value != NULL) {
tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
if (tcl_ret == TCL_OK) {
pathinfo->time = attr_value_wide;
}
|
︙ | | | ︙ | |
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
case APPFS_PATHTYPE_INVALID:
retval = -EIO;
break;
}
if (pathinfo.packaged) {
if (0) {
stbuf->st_mode |= 0222;
}
}
return(retval);
}
static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
Tcl_Interp *interp;
|
<
|
<
|
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
case APPFS_PATHTYPE_INVALID:
retval = -EIO;
break;
}
if (pathinfo.packaged) {
stbuf->st_mode |= 0222;
}
return(retval);
}
static int appfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
Tcl_Interp *interp;
|
︙ | | | ︙ | |
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
return(-EIO);
}
read_ret = read(fi->fh, buf, size);
return(read_ret);
}
/*
* SQLite3 mode: Execute raw SQL and return success or failure
*/
static int appfs_sqlite3(const char *sql) {
Tcl_Interp *interp;
const char *sql_ret;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
return(-EIO);
}
read_ret = read(fi->fh, buf, size);
return(read_ret);
}
static int appfs_fuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
off_t lseek_ret;
ssize_t write_ret;
APPFS_DEBUG("Enter (path = %s, ...)", path);
lseek_ret = lseek(fi->fh, offset, SEEK_SET);
if (lseek_ret != offset) {
return(-EIO);
}
write_ret = write(fi->fh, buf, size);
return(write_ret);
}
/*
* SQLite3 mode: Execute raw SQL and return success or failure
*/
static int appfs_sqlite3(const char *sql) {
Tcl_Interp *interp;
const char *sql_ret;
|
︙ | | | ︙ | |
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
|
*/
static struct fuse_operations appfs_operations = {
.getattr = appfs_fuse_getattr,
.readdir = appfs_fuse_readdir,
.readlink = appfs_fuse_readlink,
.open = appfs_fuse_open,
.release = appfs_fuse_close,
.read = appfs_fuse_read
};
/*
* FUSE option parsing callback
*/
static int appfs_fuse_opt_cb(void *data, const char *arg, int key, struct fuse_args *outargs) {
static int seen_cachedir = 0;
|
|
>
|
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
|
*/
static struct fuse_operations appfs_operations = {
.getattr = appfs_fuse_getattr,
.readdir = appfs_fuse_readdir,
.readlink = appfs_fuse_readlink,
.open = appfs_fuse_open,
.release = appfs_fuse_close,
.read = appfs_fuse_read,
.write = appfs_fuse_write
};
/*
* FUSE option parsing callback
*/
static int appfs_fuse_opt_cb(void *data, const char *arg, int key, struct fuse_args *outargs) {
static int seen_cachedir = 0;
|
︙ | | | ︙ | |