?? grub-0.97-patch3-ntfs
字號:
++ default:+#ifdef DEBUG_NTFS+printf("compressed\n");+#endif+ index16 = 0;+ dcvcn = vcn;+ dcoff = vcn * clustersize;+ dcrem = cmft->attr_inited - dcoff;+ if(dcrem > 16 * clustersize)+ dcrem = 16 * clustersize;+ dcsptr = dcsbuf;+ dcslen = 0;+ }+ }+ if(len0) {+#ifdef DEBUG_NTFS+printf("reading uninitialized data 3\n");+#endif+ memset(buf, 0, len0);+ filepos += len0;+ ret += len0;+ }+#else+ errnum = ERR_FSYS_CORRUPT; +#endif /*NO_NTFS_DECOMPRESSION*/+#endif /*STAGE1_5*/+ return ret;+}++int ntfs_mount (void)+{+ char *sb = (char *)FSYS_BUF;+ int mft_record;+ int spc;++ if (((current_drive & 0x80) || (current_slice != 0))+ && (current_slice != /*PC_SLICE_TYPE_NTFS*/7)+ && (current_slice != /*PC_SLICE_TYPE_NTFS*/0x17))+ return 0;++ if (!devread (0, 0, 512, (char *) FSYS_BUF))+ return 0; /* Cannot read superblock */++ if(sb[3]!='N' || sb[4]!='T' || sb[5]!='F' || sb[6]!='S')+ return 0;+ blocksize = *(__u16 *)(sb+0xb);+ spc = *(unsigned char *)(sb+0xd);+ clustersize = spc * blocksize;+ mft_record_size = *(char *)(sb+0x40);+ index_record_size = *(char *)(sb+0x44);+ if(mft_record_size>0)+ mft_record_size *= clustersize;+ else+ mft_record_size = 1 << (-mft_record_size);++ index_record_size *= clustersize;+ mft_record = *(__u32 *)(sb+0x30); /* only support 32 bit */+ spc = clustersize / 512;++ if(mft_record_size > MAX_MFT_RECORD_SIZE || index_record_size > MAX_INDEX_RECORD_SIZE) {+ /* only support 1k MFT record, 4k INDEX record */+ return 0;+ }++#ifdef DEBUG_NTFS+ printf("spc=%x mft_record=%x:%x\n", spc, *(__s64 *)(sb+0x30));+#endif++ if (!devread (mft_record*spc, 0, mft_record_size, mmft->mft))+ return 0; /* Cannot read superblock */++ if(!fixup_record( mmft->mft, "FILE", mft_record_size))+ return 0;++#ifndef NO_ALTERNATE_DATASTREAM+ is_ads_completion = 0;+#endif+ if(!search_attribute(mmft, at_data, NONAME)) return 0;++ *mft_run = mmft->runl;++ *path_ino = FILE_ROOT;++ return 1;+}++int+ntfs_dir (char *dirname)+{+ char *rest, ch;+ int namelen;+ int depth = 0;+ int chk_sfn = 1;+ int flag = 0;+ int record_offset;+ int my_index_record_size;+ unsigned char *index_entry = 0, *entry, *index_end;+ int i;++ /* main loop to find desired directory entry */+loop:++#ifdef DEBUG_NTFS+ printf("dirname=%s\n", dirname);+#endif+ if(!read_mft_record(path_ino[depth], cmft->mft, 0))+ {+#ifdef DEBUG_NTFS+ printf("MFT error 1\n");+#endif+ errnum = ERR_FSYS_CORRUPT;+ return 0;+ }++ /* if we have a real file (and we're not just printing possibilities),+ then this is where we want to exit */++ if (!*dirname || isspace (*dirname) || *dirname==':')+ {+#ifndef STAGE1_5+#ifndef NO_ALTERNATE_DATASTREAM+ if (*dirname==':' && print_possibilities) {+ char *tmp;++ /* preparing ADS name completion */+ for(tmp = dirname; *tmp != '/'; tmp--);+ for(tmp++, rest=fnbuf; *tmp && !isspace(*tmp); *rest++ = *tmp++)+ if(*tmp==':') dirname = rest;+ *rest++ = '\0';++ is_ads_completion = 1;+ search_attribute(cmft, at_data, dirname+1);+ is_ads_completion = 0;++ if(errnum==0) {+ if(print_possibilities < 0)+ return 1;+ errnum = ERR_FILE_NOT_FOUND;+ }+ return 0;+ }+#endif+#endif++ if (*dirname==':') dirname++;+ for (rest = dirname; (ch = *rest) && !isspace (ch); rest++);+ *rest = 0;++#ifdef DEBUG_NTFS+ printf("got file: search at_data\n");+#endif++ if (!search_attribute(cmft, at_data, dirname)) {+ errnum = *(dirname-1)==':'?ERR_FILE_NOT_FOUND:ERR_BAD_FILETYPE;+ *rest = ch;+ return 0;+ }+ *rest = ch;++ filemax = cmft->attr_size;+#ifdef DEBUG_NTFS+ printf("filemax=%x\n", filemax);+#endif+ return 1;+ }++ if(depth >= (MAX_DIR_DEPTH-1)) {+ errnum = ERR_FSYS_CORRUPT;+ return 0;+ }++ /* continue with the file/directory name interpretation */++ while (*dirname == '/')+ dirname++;++ for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/' && ch != ':'; rest++);++ *rest = 0;++ if (!search_attribute(cmft, at_index_root, "$I30"))+ {+ errnum = ERR_BAD_FILETYPE;+ return 0;+ }++ read_attribute(cmft, 0, fnbuf, 16, 0);+ my_index_record_size = *(__u32 *)(fnbuf+8);++ if(my_index_record_size > MAX_INDEX_RECORD_SIZE) {+ errnum = ERR_FSYS_CORRUPT;+ return 0;+ }++#ifdef DEBUG_NTFS+ printf("index_record_size=%x\n", my_index_record_size);+#endif++ if(cmft->attr_size > MAX_INDEX_RECORD_SIZE) {+ errnum = ERR_FSYS_CORRUPT;+ return 0;+ }+ read_attribute(cmft, 0, index_data, cmft->attr_size, 0);+ index_end = (unsigned char *)(index_data + cmft->attr_size);+ index_entry = (unsigned char *)(index_data + 0x20);+ record_offset = -1;++#ifndef STAGE1_5+ if (print_possibilities && ch != '/' && ch != ':' && !*dirname)+ {+ print_possibilities = -print_possibilities;+ /* fake '.' for empty directory */+ print_a_completion (".");+ }+#endif++ if (search_attribute(cmft, at_bitmap, "$I30")) {+ if(cmft->attr_size > MAX_INDEX_BITMAP_SIZE) {+ errnum = ERR_FSYS_CORRUPT;+ return 0;+ }++ read_attribute(cmft, 0, (char *)bitmap_data, cmft->attr_size, 0);++ if (search_attribute(cmft, at_index_allocation, "$I30")==0) {+ errnum = ERR_FSYS_CORRUPT;+ return 0;+ }++ for(record_offset = 0; record_offset*my_index_record_size<cmft->attr_size; record_offset++){+ int bit = 1 << (record_offset&3);+ int byte = record_offset>>3;+#ifdef DEBUG_NTFS+ printf("record_offset=%x\n", record_offset);+#endif+ if((bitmap_data[byte]&bit))+ break;+ }++ if(record_offset*my_index_record_size>=cmft->attr_size) record_offset = -1;+ }++ do+ {+ entry = index_entry; index_entry += *(__u16 *)(entry+8);+ if(entry+0x50>=index_entry||entry>=index_end||+ index_entry>=index_end||(entry[0x12]&2)){+ if(record_offset < 0 ||+ !read_attribute(cmft, record_offset*my_index_record_size, index_data, my_index_record_size, 0)){+ if (!errnum)+ {+ if (print_possibilities < 0)+ {+#if 0+ putchar ('\n');+#endif+ return 1;+ }++ errnum = ERR_FILE_NOT_FOUND;+ *rest = ch;+ }++ return 0;+ }+ if(!fixup_record( index_data, "INDX", my_index_record_size))+ {+#ifdef DEBUG_NTFS+ printf("index error\n");+#endif+ errnum = ERR_FSYS_CORRUPT;+ return 0;+ }+ entry = (unsigned char *)(index_data + 0x18 + *(__u16 *)(index_data+0x18));+ index_entry = entry + *(__u16 *)(entry+8);+ index_end = (unsigned char *)(index_data + my_index_record_size - 0x52);+ for(record_offset++; record_offset*my_index_record_size<cmft->attr_size; record_offset++){+ int bit = 1 << (record_offset&3);+ int byte = record_offset>>3;+ if((bitmap_data[byte]&bit)) break;+ }+ if(record_offset*my_index_record_size>=cmft->attr_size) record_offset = -1;+#ifdef DEBUG_NTFS+ printf("record_offset=%x\n", record_offset);+#endif+ }+ flag = entry[0x51];+ path_ino[depth+1] = *(__u32 *)entry;+ if(path_ino[depth+1] < 16)+ continue;+ namelen = entry[0x50];+ //if(index_data[0x48]&2) printf("hidden file\n");+#ifndef STAGE1_5+ /* skip short file name */+ if( flag == 2 && print_possibilities && ch != '/' && ch != ':' )+ continue;+#endif++ for( i = 0, entry+=0x52; i < namelen; i++, entry+=2 )+ {+ int c = *(__u16 *)entry;+ if(c==' '||c>=0x100)+ fnbuf[i] = '_';+ else+ fnbuf[i] = c;+ }+ fnbuf[namelen] = 0;+#ifdef DEBUG_NTFS+ printf("FLAG: %d NAME: %s inum=%d\n", flag,fnbuf,path_ino[depth+1]);+#endif++ //uncntrl(fnbuf);++ chk_sfn = nsubstring(dirname,fnbuf);+#ifndef STAGE1_5+ if (print_possibilities && ch != '/' && ch != ':'+ && (!*dirname || chk_sfn <= 0))+ {+ if (print_possibilities > 0)+ print_possibilities = -print_possibilities;+ print_a_completion (fnbuf);+ }+#endif /* STAGE1_5 */+ }+ while (chk_sfn != 0 ||+ (print_possibilities && ch != '/' && ch != ':'));++ *(dirname = rest) = ch;++ depth++;++ /* go back to main loop at top of function */+ goto loop;+}++#ifdef DEBUG_NTFS+int dump_block(char *msg, char *buf, int size){+ int l = (size+15)/16;+ int off;+ int i, j;+ int c;+ printf("----- %s -----\n", msg);+ for( i = 0, off = 0; i < l; i++, off+=16)+ {+ if(off<16)+ printf("000%x:", off);+ else if(off<256)+ printf("00%x:", off);+ else+ printf("0%x:", off);+ for(j=0;j<16;j++)+ {+ c = buf[off+j]&0xff;+ if( c >= 16 )+ printf("%c%x",j==8?'-':' ',c);+ else+ printf("%c0%x",j==8?'-':' ',c);+ }+ printf(" ");+ for(j=0;j<16;j++) {+ char c = buf[off+j];+ printf("%c",c<' '||c>='\x7f'?'.':c);+ }+ printf("\n");+ }+}+/*#endif*/+#endif /* FSYS_NTFS */diff -Naur grub-0.97_findroot/stage2/Makefile.am grub-0.97_ntfs/stage2/Makefile.am--- grub-0.97_findroot/stage2/Makefile.am 2006-10-24 12:28:50.000000000 +0800+++ grub-0.97_ntfs/stage2/Makefile.am 2006-10-24 12:28:51.000000000 +0800@@ -4,7 +4,7 @@ # For dist target. noinst_HEADERS = apic.h defs.h dir.h disk_inode.h disk_inode_ffs.h \- fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \+ ntfs.h fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \ imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \ nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \ terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h@@ -16,12 +16,12 @@ # The library for /sbin/grub. noinst_LIBRARIES = libgrub.a libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \- disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \+ disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ntfs.c fsys_ffs.c fsys_iso9660.c \ fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \ fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \ terminfo.c tparm.c libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \- -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \+ -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_NTFS=1 -DFSYS_FFS=1 \ -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \ -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \ -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1@@ -32,23 +32,23 @@ EXTRA_PROGRAMS = nbloader.exec pxeloader.exec diskless.exec if DISKLESS_SUPPORT-pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \+pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 ntfs_stage1_5 \ ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \ nbgrub pxegrub grub.exe grldr grldr.mbr bootlace.com hmload.com noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless dosstart grldrstart mbrstart bootlacestart hmloadstart noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \- e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \+ e2fs_stage1_5.exec fat_stage1_5.exec ntfs_stage1_5.exec ffs_stage1_5.exec \ iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \ xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec dosstart.exec grldrstart.exec mbrstart.exec bootlacestart.exec hmloadstart.exec else-pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \+pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 ntfs_stage1_5 \ ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 grub.exe grldr grldr.mbr bootlace.com hmload.com noinst_DATA = pre_stage2 start start_eltorito dosstart grldrstart mbrstart bootlacestart hmloadstart noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \- e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \+ e2fs_stage1_5.exec fat_stage1_5.exec ntfs_stage1_5.exec ffs_stage1_5.exec \ iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \ xfs_stage1_5.exec dosstart.exec grldrstart.exec mbrstart.exec bootlacestart.exec hmloadstart.exec@@ -88,7 +88,7 @@ # For stage2 target. pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \ cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \- fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \+ fsys_fat.c fsys_ntfs.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \ fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \ hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)@@ -213,6 +213,15 @@ -DNO_BLOCK_FILES=1 fat_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) +# For ntfs_stage1_5 target.+ntfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \+ stage1_5.c fsys_ntfs.c bios.c+ntfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_NTFS=1 \+ -DNO_BLOCK_FILES=1+ntfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_NTFS=1 \+ -DNO_BLOCK_FILES=1+ntfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)+ # For ffs_stage1_5 target. ffs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ stage1_5.c fsys_ffs.c bios.cdiff -Naur grub-0.97_findroot/stage2/ntfs.h grub-0.97_ntfs/stage2/ntfs.h--- grub-0.97_findroot/stage2/ntfs.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_ntfs/stage2/ntfs.h 2006-10-24 12:28:51.000000000 +0800@@ -0,0 +1,34 @@+/*+ * ISO 9660 filesystem backend for GRUB (GRand Unified Bootloader)+ * including Rock Ridge Extensions support+ *+ * Copyright (C) 1998, 1999 Kousuke Takai <tak@kmc.kyoto-u.ac.jp>+ *+ * This program is free software; you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation; either version 2 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.+ */+/*+ * References:+ * linux/fs/isofs/rock.[ch]+ * mkisofs-1.11.1/diag/isoinfo.c+ * mkisofs-1.11.1/iso9660.h+ * (all are written by Eric Youngdale)+ */++#ifndef _NTFS_H_+#define _NTFS_H_++++#endif /* _NTFS_H_ */diff -Naur grub-0.97_findroot/stage2/shared.h grub-0.97_ntfs/stage2/shared.h--- grub-0.97_findroot/stage2/shared.h 2004-06-20 00:40:09.000000000 +0800+++ grub-0.97_ntfs/stage2/shared.h 2006-10-24 12:28:51.000000000 +0800@@ -212,6 +212,7 @@ #define STAGE2_ID_XFS_STAGE1_5 8 #define STAGE2_ID_ISO9660_STAGE1_5 9 #define STAGE2_ID_UFS2_STAGE1_5 10+#define STAGE2_ID_NTFS_STAGE1_5 11 #ifndef STAGE1_5 # define STAGE2_ID STAGE2_ID_STAGE2@@ -222,6 +223,8 @@ # define STAGE2_ID STAGE2_ID_E2FS_STAGE1_5 # elif defined(FSYS_FAT) # define STAGE2_ID STAGE2_ID_FAT_STAGE1_5+# elif defined(FSYS_NTFS)+# define STAGE2_ID STAGE2_ID_NTFS_STAGE1_5 # elif defined(FSYS_MINIX) # define STAGE2_ID STAGE2_ID_MINIX_STAGE1_5 # elif defined(FSYS_REISERFS)diff -Naur grub-0.97_findroot/stage2/size_test grub-0.97_ntfs/stage2/size_test--- grub-0.97_findroot/stage2/size_test 2004-05-15 03:30:52.000000000 +0800+++ grub-0.97_ntfs/stage2/size_test 2006-10-24 12:28:51.000000000 +0800@@ -44,6 +44,8 @@ # first cylinder, so the size is (63 - 1) sectors. check fat_stage1_5 31744 +check ntfs_stage1_5 31744+ # Likewise. check e2fs_stage1_5 31744
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -