Overview
Comment: | Added basic write support |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | tcl-ops |
Files: | files | file ages | folders |
SHA1: | db5fcbef28a6ac294a70d06d5c7506ad511091a1 |
User & Date: | rkeene on 2014-11-07 12:26:49 |
Other Links: | manifest | tags |
Context
2014-11-07
| ||
13:04 | Added validity checking for various types check-in: 5685a8f9a8 user: rkeene tags: tcl-ops | |
12:26 | Added basic write support check-in: db5fcbef28 user: rkeene tags: tcl-ops | |
12:13 | Added basic "open" support check-in: ebbca87b7e user: rkeene tags: tcl-ops | |
Changes
Modified appfsd.c from [a228e5eaeb] to [5b32138d43].
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 ... 399 400 401 402 403 404 405 406 407 408 409 410 411 412 ... 473 474 475 476 477 478 479 480 481 482 483 484 485 486 ... 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 ... 697 698 699 700 701 702 703 704 705 706 707 708 709 710 ... 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 |
/* 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); } ................................................................................ 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)); ................................................................................ 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; } ................................................................................ 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; ................................................................................ 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; ................................................................................ */ 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; |
| > > > > > > < | < > > > > > > > > > > > > > > > > | > |
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 ... 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 ... 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 ... 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 ... 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 ... 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
/* 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); } ................................................................................ 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)); ................................................................................ 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; } ................................................................................ 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; ................................................................................ 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; ................................................................................ */ 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; |
Modified appfsd.tcl from [23568748fe] to [1c94a0206c].
481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
switch -- $pathinfo(_type) { "toplevel" - "sites" - "packages" - "os-cpu" - "versions" { set retval(type) directory set retval(childcount) 2; } "files" { set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)] if {[file exists $localpath]} { catch { file lstat $localpath localpathinfo set retval(time) $localpathinfo(mtime) switch -- $localpathinfo(type) { |
> > |
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
switch -- $pathinfo(_type) {
"toplevel" - "sites" - "packages" - "os-cpu" - "versions" {
set retval(type) directory
set retval(childcount) 2;
}
"files" {
set retval(packaged) 1
set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)]
if {[file exists $localpath]} {
catch {
file lstat $localpath localpathinfo
set retval(time) $localpathinfo(mtime)
switch -- $localpathinfo(type) {
|