Diff

Differences From Artifact [b204b9e307]:

To Artifact [9e818b560b]:


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
	.getattr   = appfs_fuse_getattr,
	.readdir   = appfs_fuse_readdir,
	.readlink  = appfs_fuse_readlink,
	.open      = appfs_fuse_open,
	.release   = appfs_fuse_close,
	.read      = appfs_fuse_read
};


















/*
 * Entry point into this program.
 */
int main(int argc, char **argv) {
	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
	const char *cachedir = APPFS_CACHEDIR;
	int pthread_ret;










	/*
	 * Set global variables, these should be configuration options.
	 */
	globalThread.cachedir = cachedir;
	globalThread.options.writable = 1;

	/*
	 * Set global variable for "boot time" to set a time on directories
	 * that we fake.
	 */
	globalThread.boottime = time(NULL);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






<


>
>
>
>
>
>
>
>
>



|







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
	.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 seen_cachedir = 0;

	if (key == FUSE_OPT_KEY_NONOPT && seen_cachedir == 0) {
		seen_cachedir = 1;

		globalThread.cachedir = strdup(arg);

		return(0);
	}

	return(1);
}

/*
 * Entry point into this program.
 */
int main(int argc, char **argv) {
	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

	int pthread_ret;

	/*
	 * Skip passed program name
	 */
	if (argc == 0 || argv == NULL) {
		return(1);
	}
	argc--;
	argv++;

	/*
	 * Set global variables, these should be configuration options.
	 */
	globalThread.cachedir = APPFS_CACHEDIR;
	globalThread.options.writable = 1;

	/*
	 * Set global variable for "boot time" to set a time on directories
	 * that we fake.
	 */
	globalThread.boottime = time(NULL);
762
763
764
765
766
767
768












769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
	 */
	pthread_ret = pthread_key_create(&interpKey, NULL);
	if (pthread_ret != 0) {
		fprintf(stderr, "Unable to create TSD key for Tcl.  Aborting.\n");

		return(1);
	}













	/*
	 * SQLite3 mode, for running raw SQL against the cache database
	 */
	if (argc == 3 && strcmp(argv[1], "-sqlite3") == 0) {
		return(appfs_sqlite3(argv[2]));
	}

	/*
	 * Tcl mode, for running raw Tcl in the same environment AppFSd would
	 * run code.
	 */
	if (argc == 3 && strcmp(argv[1], "-tcl") == 0) {
		return(appfs_tcl(argv[2]));
	}

	/*
	 * Add FUSE arguments which we always supply
	 */
	fuse_opt_parse(&args, NULL, NULL, NULL);
	fuse_opt_add_arg(&args, "-odefault_permissions,fsname=appfs,subtype=appfsd,use_ino,kernel_cache,entry_timeout=60,attr_timeout=3600,intr,big_writes");

	if (getuid() == 0) {
		fuse_opt_parse(&args, NULL, NULL, NULL);
		fuse_opt_add_arg(&args, "-oallow_other");
	}








>
>
>
>
>
>
>
>
>
>
>
>




|
|






|
|





|







787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
	 */
	pthread_ret = pthread_key_create(&interpKey, NULL);
	if (pthread_ret != 0) {
		fprintf(stderr, "Unable to create TSD key for Tcl.  Aborting.\n");

		return(1);
	}

	/*
	 * Manually specify cache directory, without FUSE callback
	 */
	if (argc >= 2) {
		if (strcmp(argv[0], "--cachedir") == 0) {
			globalThread.cachedir = strdup(argv[1]);

			argc -= 2;
			argv += 2;
		}
	}

	/*
	 * SQLite3 mode, for running raw SQL against the cache database
	 */
	if (argc == 2 && strcmp(argv[0], "--sqlite3") == 0) {
		return(appfs_sqlite3(argv[1]));
	}

	/*
	 * Tcl mode, for running raw Tcl in the same environment AppFSd would
	 * run code.
	 */
	if (argc == 2 && strcmp(argv[0], "--tcl") == 0) {
		return(appfs_tcl(argv[1]));
	}

	/*
	 * Add FUSE arguments which we always supply
	 */
	fuse_opt_parse(&args, NULL, NULL, appfs_fuse_opt_cb);
	fuse_opt_add_arg(&args, "-odefault_permissions,fsname=appfs,subtype=appfsd,use_ino,kernel_cache,entry_timeout=60,attr_timeout=3600,intr,big_writes");

	if (getuid() == 0) {
		fuse_opt_parse(&args, NULL, NULL, NULL);
		fuse_opt_add_arg(&args, "-oallow_other");
	}