Changes In Branch tcl-ops Through [5bd7399e05] Excluding Merge-Ins
This is equivalent to a diff from 98449bcf3e to 5bd7399e05
2014-11-10
| ||
05:57 | Moved to tcl-ops branch check-in: 0effed3239 user: rkeene tags: trunk | |
2014-11-07
| ||
04:52 | Added support for an "appfs-cache" script calling sqlite3 directly in appfsd check-in: c374111c37 user: rkeene tags: tcl-ops | |
2014-11-06
| ||
18:29 | Minor update check-in: 5bd7399e05 user: rkeene tags: tcl-ops | |
17:11 | Work towards gutting AppFSd to rewrite check-in: aca3a93d56 user: rkeene tags: tcl-ops | |
16:19 | Create new branch named "tcl-ops" check-in: a80b5fa283 user: rkeene tags: tcl-ops | |
03:05 | Updated to use package name instead of hash for looking up extra files check-in: 98449bcf3e user: rkeene tags: trunk | |
02:49 | Updated to indicate only that packaged files are writable check-in: 97e72202db user: rkeene tags: trunk | |
Modified .fossil-settings/ignore-glob
from [5155de6731]
to [6f815d9a84].
1 2 3 | appfsd appfsd.o appfsd.tcl.h | > > | 1 2 3 4 5 | appfsd appfsd.o appfsd.tcl.h sha1.o sha1.tcl.h |
Modified Makefile
from [bee1193267]
to [a8fe70a2c7].
︙ | ︙ | |||
20 21 22 23 24 25 26 | TCLCONFIG_SH_PATH = $(shell echo 'puts [::tcl::pkgconfig get libdir,install]' | tclsh)/tclConfig.sh endif TCL_CFLAGS = $(shell . $(TCLCONFIG_SH_PATH); echo "$${TCL_INCLUDE_SPEC}") TCL_LIBS = $(shell . $(TCLCONFIG_SH_PATH); echo "$${TCL_LIB_SPEC}") all: appfsd | | | > > > | | | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | TCLCONFIG_SH_PATH = $(shell echo 'puts [::tcl::pkgconfig get libdir,install]' | tclsh)/tclConfig.sh endif TCL_CFLAGS = $(shell . $(TCLCONFIG_SH_PATH); echo "$${TCL_INCLUDE_SPEC}") TCL_LIBS = $(shell . $(TCLCONFIG_SH_PATH); echo "$${TCL_LIB_SPEC}") all: appfsd appfsd: appfsd.o sha1.o $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o appfsd appfsd.o sha1.o $(LIBS) appfsd.o: appfsd.c appfsd.tcl.h $(CC) $(CPPFLAGS) $(CFLAGS) -o appfsd.o -c appfsd.c sha1.o: sha1.c sha1.tcl.h $(CC) $(CPPFLAGS) $(CFLAGS) -o sha1.o -c sha1.c %.tcl.h: %.tcl sed 's@[\\"]@\\&@g;s@^@ "@;s@$$@\\n"@' $^ > $@.new mv $@.new $@ install: appfsd if [ ! -d '$(DESTDIR)$(sbindir)' ]; then mkdir -p '$(DESTDIR)$(sbindir)'; chmod 755 '$(DESTDIR)$(sbindir)'; fi cp appfsd '$(DESTDIR)$(sbindir)/' clean: rm -f appfsd appfsd.o rm -f appfsd.tcl.h rm -f sha1.o sha1.tcl.h distclean: clean .PHONY: all test clean distclean install |
Modified appfsd.c
from [251c8531b4]
to [169ff6cab0].
1 2 3 | #define FUSE_USE_VERSION 26 #include <sys/types.h> | < > > > < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #define FUSE_USE_VERSION 26 #include <sys/types.h> #include <pthread.h> #include <string.h> #include <stdarg.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <fuse.h> #include <pwd.h> #include <tcl.h> /* From sha1.c */ int Sha1_Init(Tcl_Interp *interp); #ifndef APPFS_CACHEDIR #define APPFS_CACHEDIR "/var/cache/appfs" #endif #ifdef DEBUG #define APPFS_DEBUG(x...) { fprintf(stderr, "[debug] %s:%i:%s: ", __FILE__, __LINE__, __func__); fprintf(stderr, x); fprintf(stderr, "\n"); } #else #define APPFS_DEBUG(x...) /**/ #endif static pthread_key_t interpKey; struct appfs_thread_data { const char *cachedir; time_t boottime; struct { int writable; } options; }; struct appfs_thread_data globalThread; |
︙ | ︙ | |||
61 62 63 64 65 66 67 | union { struct { int childcount; } dir; struct { int executable; off_t size; | < < < < < < < > > > > > > > > > > > > > > > > > > > > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | union { struct { int childcount; } dir; struct { int executable; off_t size; } file; struct { off_t size; char source[256]; } symlink; } typeinfo; }; static Tcl_Interp *appfs_create_TclInterp(const char *cachedir) { Tcl_Interp *interp; int tcl_ret; APPFS_DEBUG("Creating new Tcl interpreter for TID = 0x%llx", (unsigned long long) pthread_self()); interp = Tcl_CreateInterp(); if (interp == NULL) { fprintf(stderr, "Unable to create Tcl Interpreter. Aborting.\n"); return(NULL); } tcl_ret = Tcl_Init(interp); if (tcl_ret != TCL_OK) { fprintf(stderr, "Unable to initialize Tcl. Aborting.\n"); fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp)); Tcl_DeleteInterp(interp); return(NULL); } tcl_ret = Tcl_Eval(interp, "package ifneeded sha1 1.0 [list load {} sha1]"); if (tcl_ret != TCL_OK) { fprintf(stderr, "Unable to initialize Tcl SHA1. Aborting.\n"); fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp)); Tcl_DeleteInterp(interp); return(NULL); } tcl_ret = Tcl_Eval(interp, "package ifneeded appfsd 1.0 [list load {} appfsd]"); if (tcl_ret != TCL_OK) { fprintf(stderr, "Unable to initialize Tcl AppFS Package. Aborting.\n"); fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp)); Tcl_DeleteInterp(interp); return(NULL); } tcl_ret = Tcl_Eval(interp, "" |
︙ | ︙ | |||
255 256 257 258 259 260 261 | return; } return; } | < < < < < < < < < < | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | return; } return; } static uid_t appfs_get_fsuid(void) { struct fuse_context *ctx; ctx = fuse_get_context(); if (ctx == NULL) { return(1); } return(ctx->uid); } static char *appfs_get_homedir(uid_t fsuid) { struct passwd entry, *result; struct stat stbuf; char buf[1024], *retval; int gpu_ret, stat_ret; gpu_ret = getpwuid_r(fsuid, &entry, buf, sizeof(buf), &result); if (gpu_ret != 0) { |
︙ | ︙ | |||
318 319 320 321 322 323 324 | result->pw_dir, (unsigned long long) stbuf.st_uid ); return(NULL); } | | < < | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < | | < < < < < < < < < < | | < < < < < < | < < < | < < | | < < | < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | result->pw_dir, (unsigned long long) stbuf.st_uid ); return(NULL); } retval = strdup(result->pw_dir); return(retval); } static int tcl_appfs_get_homedir(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { char *homedir; if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return(TCL_ERROR); } homedir = appfs_get_homedir(appfs_get_fsuid()); if (homedir == NULL) { return(TCL_ERROR); } Tcl_SetObjResult(interp, Tcl_NewStringObj(homedir, -1)); free(homedir); return(TCL_OK); } static struct appfs_children *appfs_getchildren(const char *hostname, const char *package_hash, const char *path, int *children_count_p) { } static char *appfs_lookup_package_hash(const char *hostname, const char *package, const char *os, const char *cpuArch, const char *version) { } static int appfs_getfileinfo(const char *hostname, const char *package_hash, const char *_path, struct appfs_pathinfo *pathinfo) { } /* Generate an inode for a given path */ static long long appfs_get_path_inode(const char *path) { long long retval; const char *p; |
︙ | ︙ | |||
772 773 774 775 776 777 778 | retval %= 4294967296ULL; return(retval); } /* Get information about a path, and optionally list children */ static int appfs_get_path_info(const char *_path, struct appfs_pathinfo *pathinfo, struct appfs_children **children) { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | retval %= 4294967296ULL; return(retval); } /* Get information about a path, and optionally list children */ static int appfs_get_path_info(const char *_path, struct appfs_pathinfo *pathinfo, struct appfs_children **children) { } static int appfs_fuse_getattr(const char *path, struct stat *stbuf) { struct appfs_pathinfo pathinfo; int res = 0; APPFS_DEBUG("Enter (path = %s, ...)", path); |
︙ | ︙ | |||
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 | .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; char dbfilename[1024]; | > > > > > > > > > > > > > > | < > > > < < < < < < < | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | .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 Appfsd_Init(Tcl_Interp *interp) { #ifdef USE_TCL_STUBS if (Tcl_InitStubs(interp, TCL_VERSION, 0) == 0L) { return(TCL_ERROR); } #endif Tcl_CreateObjCommand(interp, "appfsd::get_homedir", tcl_appfs_get_homedir, NULL, NULL); Tcl_PkgProvide(interp, "appfsd", "1.0"); return(TCL_OK); } int main(int argc, char **argv) { const char *cachedir = APPFS_CACHEDIR; char dbfilename[1024]; int pthread_ret, snprintf_ret; globalThread.cachedir = cachedir; globalThread.boottime = time(NULL); globalThread.options.writable = 1; Tcl_StaticPackage(NULL, "sha1", Sha1_Init, NULL); Tcl_StaticPackage(NULL, "appfsd", Appfsd_Init, NULL); pthread_ret = pthread_key_create(&interpKey, NULL); if (pthread_ret != 0) { fprintf(stderr, "Unable to create TSD key for Tcl. Aborting.\n"); return(1); } snprintf_ret = snprintf(dbfilename, sizeof(dbfilename), "%s/%s", cachedir, "cache.db"); if (snprintf_ret >= sizeof(dbfilename)) { fprintf(stderr, "Unable to set database filename. Aborting.\n"); return(1); } return(fuse_main(argc, argv, &appfs_oper, NULL)); } |
Modified appfsd.tcl
from [86cb2b92c8]
to [1a0526f9cf].
1 2 3 4 | #! /usr/bin/env tclsh package require http 2.7 package require sqlite3 | < < | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 | #! /usr/bin/env tclsh package require http 2.7 package require sqlite3 package require sha1 namespace eval ::appfs { variable cachedir "/tmp/appfs-cache" variable ttl 3600 variable nttl 60 proc _hash_sep {hash {seps 4}} { |
︙ | ︙ |
Added sha1.c version [a59d293e66].
Modified sha1.tcl
from [a8b3b2afbe]
to [235aac1913].
|
| < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | | < < < < < | < < < < < < | < < < < < < < < | < < | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < | < < < < < < < < < | < < < < < < < < < | < < < < < < < < < | < < < < < < < < < | < | < < < < < < < < < < < < < < | | < < < < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < < < < < | < < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < | < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #! /usr/bin/env tclsh proc sha1::sha1 args { set outputmode "hex" if {[lindex $args 0] == "-hex"} { set outputmode "hex" set args [lrange $args 1 end] } elseif {[lindex $args 0] == "-bin"} { set outputmode "binary" set args [lrange $args 1 end] } if {[llength $args] == 2} { set mode [lindex $args 0] } elseif {[llength $args] == 1} { set mode "-string" } else { return -code error "wrong # args: sha1::sha1 ?-bin|-hex? ?-channel channel|-file file|string?" } switch -- $mode { "-channel" { return -code error "Not implemented" } "-file" { set output [_sha1_file [lindex $args end]] } "-string" { set output [_sha1_string [lindex $args end]] } default { return -code error "invalid mode: $mode, must be one of -channel or -file (or a plain string)" } } if {$outputmode == "hex"} { binary scan $output H* output } return $output } |