From: Martin Str|mberg Message-Id: <199901311616.RAA10584@father.ludd.luth.se> Subject: FAT32 step 2 To: djgpp-workers AT delorie DOT com (DJGPP-WORKERS) Date: Sun, 31 Jan 1999 17:16:34 +0100 (MET) X-Mailer: ELM [version 2.4ME+ PL15 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Here is step 2. This adds the FAT32 extended size flag for DOZE 7.0 and above. And my first try to invent new inode numbers. You need to have applied my FAT32 step 1 patch. Holmboe, Symphony 7, MartinS diff -ruN src.org.2/libc/dos/io/_creat.c src/libc/dos/io/_creat.c --- src.org.2/libc/dos/io/_creat.c Sat Aug 31 22:09:32 1996 +++ src/libc/dos/io/_creat.c Sun Jan 31 16:12:50 1999 @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -25,10 +26,15 @@ if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename)) return rv; - _put_path(filename); if(use_lfn) { r.x.ax = 0x716c; - r.x.bx = 0x0002; /* open r/w */ + r.x.bx = 0x1002; /* Open r/w with FAT32 extended size. */ + r.x.dx = 0x0012; /* Create, truncate if exists */ + r.x.si = __tb_offset; + } else if(7 <= (_get_dos_version(1) >> 8)) { + r.x.ax = 0x6c00; + r.x.bx = 0x1002; /* Open r/w with FAT32 extended size. */ + /* FAT32 extended size flag doesn't help on WINDOZE 4.1 (98). */ r.x.dx = 0x0012; /* Create, truncate if exists */ r.x.si = __tb_offset; } else { @@ -37,6 +43,7 @@ } r.x.cx = attrib; r.x.ds = __tb_segment; + _put_path(filename); __dpmi_int(0x21, &r); if(r.x.flags & 1) { diff -ruN src.org.2/libc/dos/io/_creat.txh src/libc/dos/io/_creat.txh --- src.org.2/libc/dos/io/_creat.txh Sun Sep 27 15:21:32 1998 +++ src/libc/dos/io/_creat.txh Sun Jan 31 16:45:26 1999 @@ -10,13 +10,22 @@ @subheading Description This is a direct connection to the MS-DOS creat function call, int -0x21, %ah = 0x3c. The file is set to binary mode. This function can -be hooked by the @xref{File System Extensions}. If you don't want this -you should use @xref{_dos_creat} or @xref{_dos_creatnew}. +0x21, %ah = 0x3c, on versions of DOS earlier than 7.0. On DOS version +7.0 or later @code{_creat} calls function int 0x21, %ax = 0x6c00. On platforms where the LFN API (@pxref{_use_lfn, LFN}) is available, @code{_creat} calls function 0x716C of Interrupt 21h, to support long file names. + +On FAT32 file systems file size bigger than ~2^31 is supported. Note +that WINDOWS 98 has a bug which only let you create this big files if +LFN is enabled. In plain DOS mode it plainly works. + +The file is set to binary mode. + +This function can be hooked by the @xref{File System Extensions}. If +you don't want this you should use @xref{_dos_creat} or +@xref{_dos_creatnew}. @subheading Return Value diff -ruN src.org.2/libc/dos/io/_creat_n.c src/libc/dos/io/_creat_n.c --- src.org.2/libc/dos/io/_creat_n.c Sun Jun 28 22:42:16 1998 +++ src/libc/dos/io/_creat_n.c Sun Jan 31 16:12:48 1999 @@ -27,6 +27,8 @@ _put_path(filename); r.x.bx = + 0x1000 | /* FAT32 extended size. */ + /* FAT32 extended size flag doesn't help on WINDOZE 4.1 (98). */ 0x2002 | (flags & 0xfff0); /* r/w, no Int 24h, use caller-defined flags */ r.x.dx = 0x0010; /* Create, fail if exists */ r.x.si = __tb_offset; diff -ruN src.org.2/libc/dos/io/_open.c src/libc/dos/io/_open.c --- src.org.2/libc/dos/io/_open.c Sat Aug 31 22:09:32 1996 +++ src/libc/dos/io/_open.c Sun Jan 31 16:09:36 1999 @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -26,12 +27,17 @@ if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename)) return rv; - _put_path(filename); if(use_lfn) { r.x.ax = 0x716c; - r.x.bx = oflag & 0xff; + r.x.bx = (oflag & 0xff) | 0x1000; /* 0x1000 is FAT32 extended size. */ r.x.dx = 1; /* Open existing file */ r.x.si = __tb_offset; + } else if(7 <= (_get_dos_version(1) >> 8)) { + r.x.ax = 0x6c00; + r.x.bx = (oflag & 0xff) | 0x1000; /* 0x1000 is FAT32 extended size. */ + /* FAT32 extended size flag doesn't help on WINDOZE 4.1 (98). */ + r.x.dx = 1; /* Open existing file */ + r.x.si = __tb_offset; } else { r.h.ah = 0x3d; r.h.al = oflag; @@ -39,6 +45,7 @@ } r.x.cx = 0; r.x.ds = __tb_segment; + _put_path(filename); __dpmi_int(0x21, &r); if(r.x.flags & 1) { diff -ruN src.org.2/libc/dos/io/_open.txh src/libc/dos/io/_open.txh --- src.org.2/libc/dos/io/_open.txh Sun Sep 27 15:21:32 1998 +++ src/libc/dos/io/_open.txh Sun Jan 31 16:45:26 1999 @@ -10,8 +10,16 @@ @subheading Description This is a direct connection to the MS-DOS open function call, int 0x21, -%ah = 0x3d. (When long file names are supported, @code{_open} calls -function 0x716c of Int 0x21.) The file is set to binary mode. +%ah = 0x3d, on versions of DOS earlier than 7.0. On DOS version 7.0 or +later @code{_open} calls function int 0x21, %ax = 0x6c00. When long +file names are supported, @code{_open} calls function 0x716c of int +0x21. + +On FAT32 file systems file size bigger than ~2^31 is supported. Note +that WINDOWS 98 has a bug which only let you create this big files if +LFN is enabled. In plain DOS mode it plainly works. + +The file is set to binary mode. This function can be hooked by the @xref{File System Extensions}. If you don't want this you should use @xref{_dos_open} (but note that the diff -ruN src.org.2/libc/posix/sys/stat/xstat.c src/libc/posix/sys/stat/xstat.c --- src.org.2/libc/posix/sys/stat/xstat.c Tue Jan 23 22:30:20 1996 +++ src/libc/posix/sys/stat/xstat.c Sun Jan 31 17:00:20 1999 @@ -159,25 +159,22 @@ { static struct name_list *name_list[256]; - /* If the st_inode is wider than a short int, we will count up - * from USHRT_MAX+1 and thus ensure there will be no clashes with - * actual cluster numbers. - * Otherwise, we must count downward from USHRT_MAX, which could + /* We count downward from INT_MAX, which could * yield two files with identical inode numbers: one from actual * DOS cluster number, and another from this function. In the - * latter case, we still have at least 80 inode numbers before + * latter case, we still have at least 80 (???) inode numbers before * we step into potentially used numbers, because some FAT entries * are reserved to mean EOF, unused entry and other special codes, * and the FAT itself uses up some clusters which aren't counted. */ - static int dir = (sizeof(ino_t) > 2 ? 1 : -1); +/* static int dir = 1; */ /* (sizeof(ino_t) > 2 ? 1 : -1); */ /* INODE_COUNT is declared LONG and not ino_t, because some DOS-based * compilers use short or unsigned short for ino_t. */ - static long inode_count = (sizeof(ino_t) > 2 + static long inode_count = INT_MAX; /* (sizeof(ino_t) > 2 ? (long)USHRT_MAX + 1L - : USHRT_MAX); + : USHRT_MAX); */ struct name_list *name_ptr, *prev_ptr; const char *p; @@ -187,7 +184,7 @@ if (xstat_count != __bss_count) { xstat_count = __bss_count; - inode_count = (sizeof(ino_t) > 2 ? (long)USHRT_MAX + 1L : USHRT_MAX); + inode_count = INT_MAX; /* (sizeof(ino_t) > 2 ? (long)USHRT_MAX + 1L : USHRT_MAX); */ memset (name_list, 0, sizeof name_list); } @@ -219,7 +216,7 @@ { ino_t retval = inode_count; - inode_count += dir; + inode_count--; /* += dir; */ return retval; } @@ -270,7 +267,7 @@ else name_list[hash] = name_ptr; retval = inode_count; - inode_count += dir; /* increment or decrement as appropriate */ + inode_count--; /* += dir; */ /* increment or decrement as appropriate */ return retval; }