--------------------- PatchSet 1505 Date: 2001/02/07 09:01:15 Author: adri Branch: sfs Tag: (none) Log: sfs_read is kind of like sfs_test, but it takes a mountpoint and an inode on the command line and dumps the contents to stdout. Useful for debugging, no? Members: src/fs/sfs/Makefile.in:1.1.2.7->1.1.2.8 src/fs/sfs/sfs_read.c:1.1->1.1.2.1 Index: squid/src/fs/sfs/Makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/sfs/Attic/Makefile.in,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- squid/src/fs/sfs/Makefile.in 4 Feb 2001 01:16:04 -0000 1.1.2.7 +++ squid/src/fs/sfs/Makefile.in 7 Feb 2001 09:01:15 -0000 1.1.2.8 @@ -1,7 +1,7 @@ # # Makefile for the sfs storage driver for the Squid Object Cache server # -# $Id: Makefile.in,v 1.1.2.7 2001/02/04 01:16:04 darius Exp $ +# $Id: Makefile.in,v 1.1.2.8 2001/02/07 09:01:15 adri Exp $ # FS = sfs @@ -38,6 +38,9 @@ test: $(SFSOBJS) sfs_test.o $(CC) $(CFLAGS) $(LDFLAGS) -DSFS_TEST -L../../../lib $(SFSOBJS) sfs_test.o sfs_shim.c ../../globals.o -lmiscutil -lm -o sfs_test +read: $(SFSOBJS) sfs_read.o + $(CC) $(CFLAGS) $(LDFLAGS) -DSFS_TEST -L../../../lib $(SFSOBJS) sfs_read.o sfs_shim.c ../../globals.o -lmiscutil -lm -o sfs_read + $(OUT): $(OBJS) @rm -f ../stamp $(AR_R) $(OUT) $(OBJS) --- /dev/null Wed Feb 14 00:48:56 2007 +++ squid/src/fs/sfs/sfs_read.c Wed Feb 14 00:49:46 2007 @@ -0,0 +1,53 @@ +/* $Id: sfs_read.c,v 1.1.2.1 2001/02/07 09:01:15 adri Exp $ */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "squid.h" +#include "sfs_defines.h" +#include "sfs_lib.h" + +int main(int argc, char *argv[]) +{ + int sfsid; + uint sfsfd; + char buf[80]; + int inode; + int err; + + /* Check args */ + if (argc < 2) { + printf("error: need mountpoint inode..\n"); + exit(1); + } + + /* get inode */ + inode = atoi(argv[2]); + if (inode < 0) { + printf("inode '%s' is an invalid number\n", argv[2]); + exit(1); + } + + sfsid = sfs_mount(argv[1]); + printf("sfsid mount = %d\n",sfsid); + if (sfsid < 0) + exit(1); + + printf("opening %d", inode); + sfsfd = sfs_open(sfsid, inode, O_CREAT, 0, _SFS_IO_SYNC, NULL); + + while ((err = sfs_read(sfsfd, buf, 512, _SFS_IO_SYNC, NULL)) > 0) { + write(1, buf, 512); + } + printf("Got %d from sfs_read\n", err); + + printf("close result = %d\n",sfs_close(sfsfd, _SFS_IO_SYNC, NULL)); + printf("umount result = %d\n",sfs_umount(sfsid, _SFS_IO_SYNC)); + exit(0); +}