From 76add3b2353d599693ecfa7631541b04e89ce200 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 14 Jun 2013 15:56:55 +0200 Subject: [PATCH] fdisk: move dos specific code Signed-off-by: Karel Zak --- fdisks/fdisk.h | 35 ----------------------------------- fdisks/fdiskdoslabel.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/fdisks/fdisk.h b/fdisks/fdisk.h index 1b717f9825..2da81c154f 100644 --- a/fdisks/fdisk.h +++ b/fdisks/fdisk.h @@ -82,37 +82,6 @@ extern unsigned int read_int_with_suffix(struct fdisk_context *cxt, extern int nowarn; -/* start_sect and nr_sects are stored little endian on all machines */ -/* moreover, they are not aligned correctly */ -static inline void -store4_little_endian(unsigned char *cp, unsigned int val) { - cp[0] = (val & 0xff); - cp[1] = ((val >> 8) & 0xff); - cp[2] = ((val >> 16) & 0xff); - cp[3] = ((val >> 24) & 0xff); -} - -static inline unsigned int read4_little_endian(const unsigned char *cp) -{ - return (unsigned int)(cp[0]) + ((unsigned int)(cp[1]) << 8) - + ((unsigned int)(cp[2]) << 16) - + ((unsigned int)(cp[3]) << 24); -} - -static inline sector_t get_nr_sects(struct partition *p) -{ - return read4_little_endian(p->size4); -} - -static inline void set_nr_sects(struct partition *p, sector_t nr_sects) -{ - store4_little_endian(p->size4, nr_sects); -} - -static inline void set_start_sect(struct partition *p, unsigned int start_sect) -{ - store4_little_endian(p->start4, start_sect); -} static inline int seek_sector(struct fdisk_context *cxt, sector_t secno) { @@ -132,8 +101,4 @@ static inline int read_sector(struct fdisk_context *cxt, sector_t secno, unsigne (ssize_t) cxt->sector_size ? -errno : 0; } -static inline sector_t get_start_sect(struct partition *p) -{ - return read4_little_endian(p->start4); -} diff --git a/fdisks/fdiskdoslabel.h b/fdisks/fdiskdoslabel.h index 02185bddec..131f296d56 100644 --- a/fdisks/fdiskdoslabel.h +++ b/fdisks/fdiskdoslabel.h @@ -30,6 +30,44 @@ static inline unsigned int part_table_flag(unsigned char *b) return ((unsigned int) b[510]) + (((unsigned int) b[511]) << 8); } + +/* start_sect and nr_sects are stored little endian on all machines */ +/* moreover, they are not aligned correctly */ +static inline void store4_little_endian(unsigned char *cp, unsigned int val) +{ + cp[0] = (val & 0xff); + cp[1] = ((val >> 8) & 0xff); + cp[2] = ((val >> 16) & 0xff); + cp[3] = ((val >> 24) & 0xff); +} + +static inline unsigned int read4_little_endian(const unsigned char *cp) +{ + return (unsigned int)(cp[0]) + ((unsigned int)(cp[1]) << 8) + + ((unsigned int)(cp[2]) << 16) + + ((unsigned int)(cp[3]) << 24); +} + +static inline sector_t get_nr_sects(struct partition *p) +{ + return read4_little_endian(p->size4); +} + +static inline void set_nr_sects(struct partition *p, sector_t nr_sects) +{ + store4_little_endian(p->size4, nr_sects); +} + +static inline void set_start_sect(struct partition *p, unsigned int start_sect) +{ + store4_little_endian(p->start4, start_sect); +} + +static inline sector_t get_start_sect(struct partition *p) +{ + return read4_little_endian(p->start4); +} + static inline sector_t get_partition_start(struct pte *pe) { return pe->offset + get_start_sect(pe->part_table); -- 2.47.2