return 0;\r
}\r
\r
+ // Sanity Check offset\r
+ if(offset > node->Size){\r
+ return 0;\r
+ }\r
+ // Clamp Size\r
+ if(length + offset > node->Size) {\r
+ length = offset - node->Size;\r
+ }\r
+ \r
// Single Cluster including offset\r
if(length + offset < bpc)\r
{\r
memcpy( buffer, (void*)( tmpBuf + offset%bpc ), length );\r
free(tmpBuf);\r
LEAVE('i', 1);\r
- return 1;\r
+ return length;\r
}\r
\r
preSkip = offset / bpc;\r
if (count == 1) {\r
free(tmpBuf);\r
LEAVE('i', 1);\r
- return 1;\r
+ return length;\r
}\r
\r
cluster = FAT_int_GetFatValue(handle, cluster);\r
--- /dev/null
+# Project: cat\r
+\r
+CC = gcc\r
+AS = nasm\r
+LD = ld\r
+RM = @rm -f\r
+\r
+COBJ = main.o
+BIN = ../cat\r
+ACESSDIR = /home/hodgeja/Projects/Acess2/Usermode\r
+\r
+INCS = -I$(ACESSDIR)/include -I./include\r
+CFLAGS = -Wall -fno-builtin -fno-stack-protector $(INCS)\r
+ASFLAGS = -felf\r
+LDFLAGS = -T $(ACESSDIR)/Libraries/acess.ld -I /Acess/Libs/ld-acess.so -lc\r
+\r
+.PHONY : all clean\r
+\r
+all: $(BIN)\r
+\r
+$(BIN): $(COBJ)\r
+ @echo --- $(LD) -o $@\r
+ @$(LD) $(LDFLAGS) -o $@ $(COBJ) -Map Map.txt\r
+ objdump -d $(BIN) > $(BIN).dsm\r
+ cp $(BIN) /mnt/AcessHDD/Acess2/\r
+\r
+clean:\r
+ $(RM) $(COBJ) $(BIN)\r
+\r
+$(COBJ): %.o: %.c\r
+ @echo --- GCC -o $@
+ @$(CC) $(CFLAGS) -c $? -o $@
+\r
--- /dev/null
+/*
+ * Acess2 CAT command
+ */
+#include <acess/sys.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define BUF_SIZE 1024
+
+int main(int argc, char *argv[])
+{
+ int fd;
+ int num;
+ char buf[BUF_SIZE+1];
+
+ if(argc < 2) {
+ printf("Usage: cat <file>\n");
+ return -1;
+ }
+
+ fd = open(argv[1], OPENFLAG_READ);
+ if(fd == -1) {
+ printf("Unable to open '%s' for reading\n", argv[1]);
+ return -1;
+ }
+
+ do {
+ num = read(fd, BUF_SIZE, buf);
+ printf("num = %i\n", num);
+ buf[num] = '\0';
+ printf("%s", buf);
+ } while(num == BUF_SIZE);
+
+ close(fd);
+ printf("\n");
+
+ return 0;
+}