took a stab at write support and turned it on. Removed getopt as its not needed.
authorSteven Edwards <winehacker@gmail.com>
Thu, 4 Aug 2005 21:42:32 +0000 (21:42 +0000)
committerSteven Edwards <winehacker@gmail.com>
Thu, 4 Aug 2005 21:42:32 +0000 (21:42 +0000)
svn path=/trunk/; revision=17049

rosapps/sysutils/dosfsck/Makefile
rosapps/sysutils/dosfsck/getopt.c [deleted file]
rosapps/sysutils/dosfsck/io.c

index c32f532..0ea3d54 100644 (file)
@@ -1,5 +1,5 @@
 CC=mingw32-gcc
-OBJECTS = getopt.o boot.o check.o common.o dosfsck.o fat.o file.o io.o lfn.o
+OBJECTS = boot.o check.o common.o dosfsck.o fat.o file.o io.o lfn.o
 
 all: dosfsck.exe
 
diff --git a/rosapps/sysutils/dosfsck/getopt.c b/rosapps/sysutils/dosfsck/getopt.c
deleted file mode 100644 (file)
index 0a37f95..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*\r
- * $Id$\r
- * This is an unpublished work copyright (c) 1998 HELIOS Software GmbH\r
- * 30827 Garbsen, Germany\r
- */\r
-\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#ifdef HAS_UNISTD\r
-# include <unistd.h>\r
-#endif\r
-\r
-char *optarg;\r
-int optind = 1;\r
-int opterr = 1;\r
-int optopt;\r
-static int subopt;\r
-static int suboptind = 1;\r
-\r
-int getopt(int argc, char *const argv[], const char * optstring)\r
-{\r
-       char *curopt;\r
-       char *p;\r
-       int cursubopt;\r
-\r
-       if (suboptind == optind-1 && argv[suboptind][subopt] != '\0') {\r
-               curopt = (char *)argv[suboptind];\r
-       } else {\r
-               curopt = (char *)argv[optind];\r
-               if (curopt == NULL || curopt[0] != '-' || strcmp(curopt, "-") == 0)\r
-                       return -1;\r
-               suboptind = optind;\r
-               subopt = 1;\r
-               optind++;\r
-               if (strcmp(curopt, "--") == 0)\r
-                       return -1;\r
-       }\r
-       cursubopt = subopt++;\r
-       if ((p = strchr(optstring, curopt[cursubopt])) == NULL) {\r
-               optopt = curopt[cursubopt];\r
-               if (opterr)\r
-                       fprintf(stderr, "%s: illegal option -- %c\n", argv[0], optopt);\r
-               return '?';\r
-       }\r
-       if (p[1] == ':') {\r
-               if (curopt[cursubopt+1] != '\0') {\r
-                       optarg = curopt+cursubopt+1;\r
-                       suboptind++;\r
-                       return p[0];\r
-               }\r
-               if (argv[optind] == NULL) {\r
-                       optopt = p[0];\r
-                       if (opterr)\r
-                               fprintf(stderr, "%s: option requires an argument -- %c\n", argv[0], optopt);\r
-                       if (*optstring == ':')\r
-                               return ':';\r
-                       return '?';\r
-               }\r
-               optarg = argv[optind++];\r
-       }\r
-       return p[0];\r
-}\r
index e4e231f..32aee9f 100644 (file)
@@ -164,7 +164,35 @@ void fs_write(loff_t pos,int size,void *data)
 {\r
     CHANGE *new;\r
     int did;\r
-\r
+
+#if 1 //SAE
+    void *scratch;
+    const size_t readsize_aligned = (size % 512) ? (size + (512 - (size % 512))) : size;\r
+    const loff_t seekpos_aligned = pos - (pos % 512);\r
+    const size_t seek_delta = (size_t)(pos - seekpos_aligned);\r
+    const size_t readsize = (size_t)(pos - seekpos_aligned) + readsize_aligned;\r
+    scratch = alloc(readsize_aligned);
+
+    if (write_immed) {\r
+       did_change = 1;\r
+       if (llseek(fd,seekpos_aligned,0) != seekpos_aligned) pdie("Seek to %lld",pos);\r
+       if ((did = write(fd,data,readsize_aligned)) == (int)readsize_aligned)
+       {
+           free(scratch);
+           return;
+       }\r
+       if (did < 0) pdie("Write %d bytes at %lld",size,pos);\r
+       die("Wrote %d bytes instead of %d at %lld",did,size,pos);\r
+    }\r
+    new = alloc(sizeof(CHANGE));\r
+    new->pos = pos;\r
+    memcpy(new->data = alloc(new->size = size),data,size);\r
+    new->next = NULL;\r
+    if (last) last->next = new;\r
+    else changes = new;\r
+    last = new;
+
+#else //SAE\r
     if (write_immed) {\r
        did_change = 1;\r
        if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos);\r
@@ -178,7 +206,8 @@ void fs_write(loff_t pos,int size,void *data)
     new->next = NULL;\r
     if (last) last->next = new;\r
     else changes = new;\r
-    last = new;\r
+    last = new;
+#endif //SAE\r
 }\r
 \r
 \r
@@ -261,22 +290,18 @@ static int WIN32open(const char *path, int oflag, ...)
                shareMode = FILE_SHARE_READ|FILE_SHARE_WRITE; // TMN:\r
                break;\r
        case O_WRONLY:\r
-               exit(42);\r
                desiredAccess = GENERIC_WRITE;\r
                shareMode = 0;\r
                break;\r
        case O_RDWR:\r
-               exit(43);\r
                desiredAccess = GENERIC_READ|GENERIC_WRITE;\r
                shareMode = 0;\r
                break;\r
        case O_NONE:\r
-               exit(44);\r
                desiredAccess = 0;\r
                shareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;\r
        }\r
        if (oflag & O_APPEND) {\r
-               exit(45);\r
                desiredAccess |= FILE_APPEND_DATA|SYNCHRONIZE;\r
                shareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;\r
        }\r
@@ -288,27 +313,22 @@ static int WIN32open(const char *path, int oflag, ...)
                creationDisposition = OPEN_EXISTING;\r
                break;\r
        case O_CREAT:\r
-               exit(46);\r
                creationDisposition = OPEN_ALWAYS;\r
                break;\r
        case O_CREAT|O_EXCL:\r
        case O_CREAT|O_TRUNC|O_EXCL:\r
-               exit(47);\r
                creationDisposition = CREATE_NEW;\r
                break;\r
        case O_TRUNC:\r
        case O_TRUNC|O_EXCL:\r
-               exit(48);\r
                creationDisposition = TRUNCATE_EXISTING;\r
                break;\r
        case O_CREAT|O_TRUNC:\r
-               exit(49);\r
                creationDisposition = OPEN_ALWAYS;\r
                trunc = TRUE;\r
                break;\r
         }\r
        if (oflag & O_CREAT) {\r
-               exit(50);\r
                va_start(ap, oflag);\r
                pmode = va_arg(ap, int);\r
                va_end(ap);\r
@@ -316,7 +336,6 @@ static int WIN32open(const char *path, int oflag, ...)
                        flagsAttributes |= FILE_ATTRIBUTE_READONLY;\r
        }\r
        if (oflag & O_TEMPORARY) {\r
-               exit(51);\r
                flagsAttributes |= FILE_FLAG_DELETE_ON_CLOSE;\r
                desiredAccess |= DELETE;\r
        }\r
@@ -334,7 +353,6 @@ static int WIN32open(const char *path, int oflag, ...)
                return -1;\r
        }\r
        if (trunc) {\r
-               exit(52);\r
                if (!SetEndOfFile(fh)) {\r
                        errno = GetLastError();\r
                        CloseHandle(fh);\r