This patch was based originally on the following file: http://lfs.vlsm.org/lfs/conglomeration/util-linux/\ util-linux-2.12r-lseek-1.patch Submitted By: Dan Nicholson Date: 2006-07-08 Initial Package Version: 2.12r Origin: Upstream Upstream Status: Applied in util-linux-2.13-pre6.tar.bz2 Description: Replaces uses of *llseek with lseek. Fixes an issue compiling util-linux with kernel headers from linux-2.6.18-rc1 headers_install. --- util-linux-2.12r.old/fdisk/Makefile +++ util-linux-2.12r/fdisk/Makefile @@ -39,7 +39,7 @@ endif endif -cfdisk: cfdisk.o llseek.o disksize.o i386_sys_types.o $(LIB)/xstrncpy.o +cfdisk: cfdisk.o disksize.o i386_sys_types.o $(LIB)/xstrncpy.o ifeq "$(HAVE_SLANG)" "yes" $(CC) $(LDFLAGS) $^ -o $@ $(LIBSLANG) else @@ -55,7 +55,7 @@ rm -f activate ln -s sfdisk activate -fdisk: fdisk.o llseek.o disksize.o fdiskbsdlabel.o fdisksgilabel.o \ +fdisk: fdisk.o disksize.o fdiskbsdlabel.o fdisksgilabel.o \ fdisksunlabel.o fdiskaixlabel.o i386_sys_types.o partname.o fdisk.o: fdisk.c fdisk.h fdiskbsdlabel.o: fdiskbsdlabel.c fdisk.h fdiskbsdlabel.h --- util-linux-2.12r.old/fdisk/cfdisk.c +++ util-linux-2.12r/fdisk/cfdisk.c @@ -84,9 +84,6 @@ #include "xstrncpy.h" #include "common.h" -extern long long ext2_llseek(unsigned int fd, long long offset, - unsigned int origin); - #define VERSION UTIL_LINUX_VERSION #define DEFAULT_DEVICE "/dev/hda" @@ -552,7 +549,7 @@ static void read_sector(char *buffer, long long sect_num) { - if (ext2_llseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0) + if (lseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0) fatal(_("Cannot seek on disk drive"), 2); if (read(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE) fatal(_("Cannot read disk drive"), 2); @@ -560,7 +557,7 @@ static void write_sector(char *buffer, long long sect_num) { - if (ext2_llseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0) + if (lseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0) fatal(_("Cannot seek on disk drive"), 2); if (write(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE) fatal(_("Cannot write disk drive"), 2); @@ -587,7 +584,7 @@ long long offset; offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE; - if (ext2_llseek(fd, offset, SEEK_SET) == offset + if (lseek(fd, offset, SEEK_SET) == offset && read(fd, §or, sizeof(sector)) == sizeof(sector)) { dos_copy_to_info(p_info[i].ostype, OSTYPESZ, sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ); @@ -672,7 +669,7 @@ offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE + 1024; - if (ext2_llseek(fd, offset, SEEK_SET) == offset + if (lseek(fd, offset, SEEK_SET) == offset && read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb) && e2fsb.s_magic[0] + (e2fsb.s_magic[1]<<8) == EXT2_SUPER_MAGIC) { label = e2fsb.s_volume_name; @@ -688,7 +685,7 @@ } offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE + 0; - if (ext2_llseek(fd, offset, SEEK_SET) == offset + if (lseek(fd, offset, SEEK_SET) == offset && read(fd, &xfsb, sizeof(xfsb)) == sizeof(xfsb) && !strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4)) { label = xfsb.s_fname; @@ -702,7 +699,7 @@ /* jfs? */ offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE + JFS_SUPER1_OFF; - if (ext2_llseek(fd, offset, SEEK_SET) == offset + if (lseek(fd, offset, SEEK_SET) == offset && read(fd, &jfsb, sizeof(jfsb)) == sizeof(jfsb) && !strncmp(jfsb.s_magic, JFS_MAGIC, strlen(JFS_MAGIC))) { label = jfsb.s_label; @@ -716,7 +713,7 @@ /* reiserfs? */ offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE + REISERFS_DISK_OFFSET_IN_BYTES; - if (ext2_llseek(fd, offset, SEEK_SET) == offset + if (lseek(fd, offset, SEEK_SET) == offset && read(fd, &reiserfsb, sizeof(reiserfsb)) == sizeof(reiserfsb) && has_reiserfs_magic_string(&reiserfsb, &reiserfs_is_3_6)) { if (reiserfs_is_3_6) { @@ -1860,7 +1857,7 @@ while (!done) { mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, - _("Are you sure you want write the partition table " + _("Are you sure you want to write the partition table " "to disk? (yes or no): ")); len = get_string(response, LINE_LENGTH, NULL); clear_warning(); --- util-linux-2.12r.old/fdisk/fdisk.c +++ util-linux-2.12r/fdisk/fdisk.c @@ -239,8 +239,8 @@ static void seek_sector(int fd, unsigned int secno) { - long long offset = (long long) secno * sector_size; - if (ext2_llseek(fd, offset, SEEK_SET) == (long long) -1) + off_t offset = (off_t) secno * sector_size; + if (lseek(fd, offset, SEEK_SET) == (off_t) -1) fatal(unable_to_seek); } --- util-linux-2.12r.old/fdisk/fdisk.h +++ util-linux-2.12r/fdisk/fdisk.h @@ -26,9 +26,6 @@ #define cround(n) (display_in_cyl_units ? ((n)/units_per_sector)+1 : (n)) #define scround(x) (((x)+units_per_sector-1)/units_per_sector) -extern long long ext2_llseek(unsigned int fd, long long offset, - unsigned int origin); - #if defined(__GNUC__) && (defined(__arm__) || defined(__alpha__)) # define PACKED __attribute__ ((packed)) #else --- util-linux-2.12r.old/fdisk/fdiskbsdlabel.c +++ util-linux-2.12r/fdisk/fdiskbsdlabel.c @@ -566,7 +566,7 @@ sector = get_start_sect(xbsd_part); #endif - if (ext2_llseek (fd, (long long) sector * SECTOR_SIZE, SEEK_SET) == -1) + if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1) fatal (unable_to_seek); if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) fatal (unable_to_write); @@ -735,7 +735,7 @@ sector = 0; #endif - if (ext2_llseek (fd, (long long) sector * SECTOR_SIZE, SEEK_SET) == -1) + if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1) fatal (unable_to_seek); if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE)) fatal (unable_to_read); @@ -781,12 +781,12 @@ #if defined (__alpha__) && BSD_LABELSECTOR == 0 alpha_bootblock_checksum (disklabelbuffer); - if (ext2_llseek (fd, (long long) 0, SEEK_SET) == -1) + if (lseek (fd, (off_t) 0, SEEK_SET) == -1) fatal (unable_to_seek); if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) fatal (unable_to_write); #else - if (ext2_llseek (fd, (long long) sector * SECTOR_SIZE + BSD_LABELOFFSET, + if (lseek (fd, (off_t) sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) fatal (unable_to_seek); if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel))) --- util-linux-2.12r.old/fdisk/fdisksgilabel.c +++ util-linux-2.12r/fdisk/fdisksgilabel.c @@ -379,7 +379,7 @@ */ sgiinfo *info = fill_sgiinfo(); int infostartblock = SSWAP32(sgilabel->directory[0].vol_file_start); - if (ext2_llseek(fd, (long long)infostartblock* + if (lseek(fd, (off_t) infostartblock* SECTOR_SIZE, SEEK_SET) < 0) fatal(unable_to_seek); if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE) --- util-linux-2.12r.old/fdisk/sfdisk.c +++ util-linux-2.12r/fdisk/sfdisk.c @@ -164,36 +164,17 @@ /* * sseek: seek to specified sector - return 0 on failure * - * For >4GB disks lseek needs a > 32bit arg, and we have to use llseek. - * On the other hand, a 32 bit sector number is OK until 2TB. - * The routines _llseek and sseek below are the only ones that - * know about the loff_t type. - * * Note: we use 512-byte sectors here, irrespective of the hardware ss. */ -#undef use_lseek -#if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (__s390x__) -#define use_lseek -#endif - -#ifndef use_lseek -static __attribute__used -_syscall5(int, _llseek, unsigned int, fd, ulong, hi, ulong, lo, - loff_t *, res, unsigned int, wh); -#endif static int sseek(char *dev, unsigned int fd, unsigned long s) { - loff_t in, out; - in = ((loff_t) s << 9); + off_t in, out; + in = ((off_t) s << 9); out = 1; -#ifndef use_lseek - if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0) { -#else if ((out = lseek(fd, in, SEEK_SET)) != in) { -#endif - perror("llseek"); + perror("lseek"); error(_("seek error on %s - cannot seek to %lu\n"), dev, s); return 0; } --- util-linux-2.12r.old/partx/partx.c +++ util-linux-2.12r/partx/partx.c @@ -330,34 +330,15 @@ return t; } -/* - * sseek: seek to specified sector - */ -#if !defined (__alpha__) && !defined (__ia64__) && !defined (__s390x__) && !defined(__x86_64__) -#define NEED__llseek -#endif - -#ifdef NEED__llseek -#include /* _syscall */ -static -_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, - long long *, res, uint, wh); -#endif - static int sseek(int fd, unsigned int secnr) { long long in, out; in = ((long long) secnr << 9); out = 1; -#ifdef NEED__llseek - if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0 - || out != in) -#else if ((out = lseek(fd, in, SEEK_SET)) != in) -#endif { - fprintf(stderr, "llseek error\n"); + fprintf(stderr, "lseek error\n"); return -1; } return 0;