1
0
forked from pool/util-linux
util-linux/util-linux-2.12r-fdisk_llseek.patch

235 lines
7.4 KiB
Diff

--- fdisk/Makefile
+++ 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 fdisksunlabel.o \
+fdisk: fdisk.o disksize.o fdiskbsdlabel.o fdisksgilabel.o fdisksunlabel.o \
fdiskmaclabel.o fdiskaixlabel.o i386_sys_types.o partname.o
fdisk.o: fdisk.c fdisk.h
fdiskbsdlabel.o: fdiskbsdlabel.c fdisk.h fdiskbsdlabel.h
--- fdisk/cfdisk.c
+++ 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, &sector, 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) {
--- fdisk/fdiskbsdlabel.c
+++ 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, (long long) 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, (long long) 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, (long long) 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, (long long) sector * SECTOR_SIZE + BSD_LABELOFFSET,
SEEK_SET) == -1)
fatal (unable_to_seek);
if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel)))
--- fdisk/fdisksgilabel.c
+++ 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, (long long)infostartblock*
SECTOR_SIZE, SEEK_SET) < 0)
fatal(unable_to_seek);
if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE)
--- fdisk/llseek.c
+++ fdisk/llseek.c
@@ -13,31 +13,12 @@
extern long long ext2_llseek (unsigned int, long long, unsigned int);
#ifdef __linux__
-
-#ifdef HAVE_LLSEEK
-#include <syscall.h>
-
-#else /* HAVE_LLSEEK */
-
-#if defined(__alpha__) || defined(__ia64__) || defined(__s390x__)
-
-#define my_llseek lseek
-
-#else
-#include <linux/unistd.h> /* for __NR__llseek */
-
-static int _llseek (unsigned int, unsigned long,
- unsigned long, long long *, unsigned int);
-
-#ifdef __NR__llseek
-
-static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high,
- unsigned long, offset_low,long long *,result,
- unsigned int, origin)
-
-#else
+# if defined(__alpha__) || defined(__ia64__) || defined(__s390x__)
+# define my_llseek lseek
+# else
/* no __NR__llseek on compilation machine - might give it explicitly */
+# ifndef __NR__llseek
static int _llseek (unsigned int fd, unsigned long oh,
unsigned long ol, long long *result,
unsigned int origin) {
@@ -45,10 +26,10 @@
return -1;
}
-#endif
+# endif /* __NR__llseek */
static long long my_llseek (unsigned int fd, long long offset,
- unsigned int origin)
+ unsigned int origin)
{
long long result;
int retval;
--- fdisk/sfdisk.c
+++ fdisk/sfdisk.c
@@ -164,36 +164,16 @@
/*
* 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;
}