[syslinux] add support for 4K sector size

* Also add 4K sector size support in ms-sys
This commit is contained in:
Pete Batard 2015-06-02 21:47:44 +01:00
parent bf967dc39b
commit 9e7b0bad89
8 changed files with 75 additions and 42 deletions

View file

@ -29,10 +29,10 @@ void *libfat_get_sector(struct libfat_filesystem *fs, libfat_sector_t n)
}
/* Not found in cache */
ls = malloc(sizeof(struct libfat_sector));
ls = malloc(sizeof(struct libfat_sector) + LIBFAT_SECTOR_SIZE);
if (!ls) {
libfat_flush(fs);
ls = malloc(sizeof(struct libfat_sector));
ls = malloc(sizeof(struct libfat_sector) + LIBFAT_SECTOR_SIZE);
if (!ls)
return NULL; /* Can't allocate memory */

View file

@ -22,9 +22,14 @@
#include <stddef.h>
#include <inttypes.h>
#define LIBFAT_SECTOR_SHIFT 9
#define LIBFAT_SECTOR_SIZE 512
#define LIBFAT_SECTOR_MASK 511
// Workaround for 4K support
extern uint32_t LIBFAT_SECTOR_SHIFT;
extern uint32_t LIBFAT_SECTOR_SIZE;
extern uint32_t LIBFAT_SECTOR_MASK;
#define MAX_LIBFAT_SECTOR_SIZE 4096
//#define LIBFAT_SECTOR_SHIFT 9
//#define LIBFAT_SECTOR_SIZE 512
//#define LIBFAT_SECTOR_MASK 511
typedef uint64_t libfat_sector_t;
struct libfat_filesystem;

View file

@ -25,7 +25,7 @@
struct libfat_sector {
libfat_sector_t n; /* Sector number */
struct libfat_sector *next; /* Next in list */
char data[LIBFAT_SECTOR_SIZE];
char data[0];
};
enum fat_type {

View file

@ -25,7 +25,7 @@ int32_t libfat_searchdir(struct libfat_filesystem *fs, int32_t dirclust,
const void *name, struct libfat_direntry *direntry)
{
struct fat_dirent *dep;
int nent;
unsigned int nent;
libfat_sector_t s = libfat_clustertosector(fs, dirclust);
while (1) {

View file

@ -41,8 +41,11 @@ extern const unsigned int syslinux_mbr_len;
extern const int syslinux_mbr_mtime;
/* Sector size assumptions... */
#define SECTOR_SHIFT 9
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
// Workaround for 4K support
extern uint32_t SECTOR_SHIFT;
extern uint32_t SECTOR_SIZE;
//#define SECTOR_SHIFT 9
//#define SECTOR_SIZE (1 << SECTOR_SHIFT)
/* This takes a boot sector and merges in the syslinux fields */
void syslinux_make_bootsect(void *bs, int fs_type);