Check-in [8ea4ed266f]
Overview
Comment:Added a truncate action
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tcl-ops
Files: files | file ages | folders
SHA1:8ea4ed266ffe590cb66cae0b1b7ad56a0ddc5357
User & Date: rkeene on 2014-11-09 08:01:16
Other Links: manifest | tags
Context
2014-11-09
09:04
More work towards a writable solution check-in: 1adf504f9a user: rkeene tags: tcl-ops
08:01
Added a truncate action check-in: 8ea4ed266f user: rkeene tags: tcl-ops
07:52
Began adding support for other types of files as well as added creat() and mknod() support check-in: 80bcdf4cb8 user: rkeene tags: tcl-ops
Changes

Modified appfsd.c from [ba1c738961] to [6a9a58fb18].

552
553
554
555
556
557
558


























559
560
561
562
563
564
565
...
830
831
832
833
834
835
836




















837
838
839
840
841
842
843
...
925
926
927
928
929
930
931

932
933
934
935
936
937
938
	real_path = Tcl_GetStringResult(interp);
	if (real_path == NULL) {
		return(NULL);
	}

	return(strdup(real_path));
}



























static int appfs_fuse_readlink(const char *path, char *buf, size_t size) {
	struct appfs_pathinfo pathinfo;
	int retval = 0;

	APPFS_DEBUG("Enter (path = %s, ...)", path);

................................................................................
		close(fd);

		return(-EIO);
	}

	return(fd);
}





















/*
 * SQLite3 mode: Execute raw SQL and return success or failure
 */
static int appfs_sqlite3(const char *sql) {
	Tcl_Interp *interp;
	const char *sql_ret;
................................................................................
	.readlink  = appfs_fuse_readlink,
	.open      = appfs_fuse_open,
	.release   = appfs_fuse_close,
	.read      = appfs_fuse_read,
	.write     = appfs_fuse_write,
	.mknod     = appfs_fuse_mknod,
	.create    = appfs_fuse_create,

};

/*
 * 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;







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







 







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







 







>







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
583
584
585
586
587
588
589
590
591
...
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
...
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
	real_path = Tcl_GetStringResult(interp);
	if (real_path == NULL) {
		return(NULL);
	}

	return(strdup(real_path));
}

static char *appfs_localpath(const char *path) {
	Tcl_Interp *interp;
	const char *real_path;
	int tcl_ret;

	interp = appfs_TclInterp();
	if (interp == NULL) {
		return(NULL);
	}

	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::localpath", path);
	if (tcl_ret != TCL_OK) {
		APPFS_DEBUG("::appfs::localpath(%s) failed.", path);
		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));

		return(NULL);
	}

	real_path = Tcl_GetStringResult(interp);
	if (real_path == NULL) {
		return(NULL);
	}

	return(strdup(real_path));
}

static int appfs_fuse_readlink(const char *path, char *buf, size_t size) {
	struct appfs_pathinfo pathinfo;
	int retval = 0;

	APPFS_DEBUG("Enter (path = %s, ...)", path);

................................................................................
		close(fd);

		return(-EIO);
	}

	return(fd);
}

static int appfs_fuse_truncate(const char *path, off_t size) {
	char *real_path;
	int truncate_ret;

	real_path = appfs_localpath(path);
	if (real_path == NULL) {
		return(-EIO);
	}

	truncate_ret = truncate(real_path, size);

	free(real_path);

	if (truncate_ret != 0) {
		return(errno * -1);
	}

	return(truncate_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;
................................................................................
	.readlink  = appfs_fuse_readlink,
	.open      = appfs_fuse_open,
	.release   = appfs_fuse_close,
	.read      = appfs_fuse_read,
	.write     = appfs_fuse_write,
	.mknod     = appfs_fuse_mknod,
	.create    = appfs_fuse_create,
	.truncate  = appfs_fuse_truncate,
};

/*
 * 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 [a96ad61fba] to [3cd77a5342].

664
665
666
667
668
669
670
671



























		set dirname [file dirname $filename]

		file mkdir $dirname

		return $filename
	}
}

































|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697

		set dirname [file dirname $filename]

		file mkdir $dirname

		return $filename
	}

	proc prepare_to_create {path} {
		if {[exists $path] != ""} {
			return -code error "File already exists"
		}

		set filename [openpath $path "create"]

		set dirname [file dirname $filename]

		file mkdir $dirname

		return $filename
	}

	proc localpath {path} {
		array set pathinfo [_parsepath $path]

		if {$pathinfo(_type) != "files"} {
			return -code error "invalid type"
		}

		set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)]

		return $localpath
	}
}