Changeset b0ac906b283b428ba1c7f35fe1e71a84b3d3d9c6 for extlinux
- Timestamp:
- 09/07/11 07:19:05 (9 months ago)
- Children:
- 045bc5cd1118fee51b19d89dc316038c8a93e5bf
- Parents:
- 67954e370003d9bbfd8b58042669f2e9d532636f
- git-author:
- Paulo Alcantara <pcacjr@gmail.com> / 2011-07-05T21:32:51Z+0000
- git-committer:
- Paulo Alcantara <pcacjr@gmail.com> / 2011-09-07T07:19:05Z+0000
- Location:
- extlinux
- Files:
-
- 1 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
extlinux/Makefile
r261317 rb0ac90 12 12 13 13 ## 14 ## Linux vfat, ext2/ext3/ext4 and btrfs installer14 ## Linux vfat, ntfs, ext2/ext3/ext4 and btrfs installer 15 15 ## 16 16 -
extlinux/main.c
rc210e5 rb0ac90 15 15 * extlinux.c 16 16 * 17 * Install the syslinux boot block on an fat, ext2/3/4 and btrfs filesystem17 * Install the syslinux boot block on an fat, ntfs, ext2/3/4 and btrfs filesystem 18 18 */ 19 19 … … 46 46 #include "btrfs.h" 47 47 #include "fat.h" 48 #include "ntfs.h" 48 49 #include "../version.h" 49 50 #include "syslxint.h" 50 51 #include "syslxcom.h" /* common functions shared with extlinux and syslinux */ 52 #include "syslxfs.h" 51 53 #include "setadv.h" 52 54 #include "syslxopt.h" /* unified options */ … … 215 217 uint64_t totalbytes, totalsectors; 216 218 int nsect; 217 struct boot_sector *sbs;219 struct fat_boot_sector *sbs; 218 220 char *dirpath, *subpath, *xdirpath; 219 221 int rv; … … 272 274 dprintf("heads = %u, sect = %u\n", geo.heads, geo.sectors); 273 275 274 sbs = (struct boot_sector *)syslinux_bootsect;276 sbs = (struct fat_boot_sector *)syslinux_bootsect; 275 277 276 278 totalsectors = totalbytes >> SECTOR_SHIFT; … … 293 295 nsect += 2; /* Two sectors for the ADV */ 294 296 sectp = alloca(sizeof(sector_t) * nsect); 295 if (fs_type == EXT2 || fs_type == VFAT ) {297 if (fs_type == EXT2 || fs_type == VFAT || fs_type == NTFS) { 296 298 if (sectmap(fd, sectp, nsect)) { 297 299 perror("bmap"); … … 324 326 struct ext2_super_block sb; 325 327 struct btrfs_super_block sb2; 326 struct boot_sector sb3; 328 struct fat_boot_sector sb3; 329 struct ntfs_boot_sector sb4; 327 330 bool ok = false; 328 331 … … 349 352 if (fat_check_sb_fields(&sb3)) 350 353 ok = true; 354 } else if (fs_type == NTFS) { 355 if (xpread(fd, &sb4, sizeof(sb4), 0) != sizeof(sb4)) { 356 perror("reading ntfs superblock"); 357 return 1; 358 } 359 360 if (ntfs_check_sb_fields(&sb4)) 361 ok = true; 351 362 } 352 363 if (!ok) { 353 fprintf(stderr, "no fat, ext2/3/4 or btrfs superblock found on %s\n",364 fprintf(stderr, "no fat, ntfs, ext2/3/4 or btrfs superblock found on %s\n", 354 365 device); 355 366 return 1; 356 367 } 357 368 if (fs_type == VFAT) { 358 struct boot_sector *sbs = (structboot_sector *)syslinux_bootsect;359 if (xpwrite(fd, &sbs-> bsHead, bsHeadLen, 0) !=bsHeadLen ||360 xpwrite(fd, &sbs-> bsCode,bsCodeLen,361 offsetof(struct boot_sector, bsCode)) !=bsCodeLen) {369 struct fat_boot_sector *sbs = (struct fat_boot_sector *)syslinux_bootsect; 370 if (xpwrite(fd, &sbs->FAT_bsHead, FAT_bsHeadLen, 0) != FAT_bsHeadLen || 371 xpwrite(fd, &sbs->FAT_bsCode, FAT_bsCodeLen, 372 offsetof(struct fat_boot_sector, FAT_bsCode)) != FAT_bsCodeLen) { 362 373 perror("writing fat bootblock"); 363 374 return 1; 364 375 } 376 } else if (fs_type == NTFS) { 377 struct ntfs_boot_sector *sbs = 378 (struct ntfs_boot_sector *)syslinux_bootsect; 379 if (xpwrite(fd, &sbs->NTFS_bsHead, 380 NTFS_bsHeadLen, 0) != NTFS_bsHeadLen || 381 xpwrite(fd, &sbs->NTFS_bsCode, NTFS_bsCodeLen, 382 offsetof(struct ntfs_boot_sector, 383 NTFS_bsCode)) != NTFS_bsCodeLen) { 384 perror("writing ntfs bootblock"); 385 return 1; 386 } 365 387 } else { 366 388 if (xpwrite(fd, syslinux_bootsect, syslinux_bootsect_len, 0) … … 755 777 int install_file(const char *path, int devfd, struct stat *rst) 756 778 { 757 if (fs_type == EXT2 || fs_type == VFAT )779 if (fs_type == EXT2 || fs_type == VFAT || fs_type == NTFS) 758 780 return ext2_fat_install_file(path, devfd, rst); 759 781 else if (fs_type == BTRFS) … … 829 851 break; 830 852 } 853 case NTFS: 854 if ((!strcmp(mnt->mnt_type, "fuseblk") /* ntfs-3g */ || 855 !strcmp(mnt->mnt_type, "ntfs")) && 856 !stat(mnt->mnt_fsname, &dst) && 857 dst.st_rdev == dev) { 858 done = true; 859 break; 860 } 861 862 break; 831 863 case NONE: 832 864 break; … … 911 943 else if (sfs.f_type == MSDOS_SUPER_MAGIC) 912 944 fs_type = VFAT; 945 else if (sfs.f_type == NTFS_SB_MAGIC || 946 sfs.f_type == FUSE_SUPER_MAGIC /* ntfs-3g */) 947 fs_type = NTFS; 913 948 914 949 if (!fs_type) { 915 fprintf(stderr, "%s: not a fat, ext2/3/4 or btrfs filesystem: %s\n",950 fprintf(stderr, "%s: not a fat, ntfs, ext2/3/4 or btrfs filesystem: %s\n", 916 951 program, path); 917 952 return -1;
