aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-07-14 19:03:14 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-07-14 19:03:14 +0000
commitde2b0e40ed5ae8cb6bcc058bba18852f4404bc48 (patch)
treeda68354bb2864300b34781fa6ca01a67a5aad48a
parentb1a79522c949e2108d91a2c00e0ddcbd1dfebd96 (diff)
downloadbusybox-w32-de2b0e40ed5ae8cb6bcc058bba18852f4404bc48.tar.gz
busybox-w32-de2b0e40ed5ae8cb6bcc058bba18852f4404bc48.tar.bz2
busybox-w32-de2b0e40ed5ae8cb6bcc058bba18852f4404bc48.zip
Remove all the llseek junk and just use regular old lseek. When DOLFS is
enabled, regular lseek is transparently promoted to lseek64 anyways, rendering the llseek stuff pointless. -Erik git-svn-id: svn://busybox.net/trunk/busybox@7052 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--util-linux/fdisk.c116
1 files changed, 6 insertions, 110 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 11da77179..291be4b9b 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -838,110 +838,6 @@ typedef struct {
838#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) \ 838#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) \
839 : (uint32_t)(x)) 839 : (uint32_t)(x))
840 840
841/*
842 * llseek.c -- stub calling the llseek system call
843 *
844 * Copyright (C) 1994 Remy Card. This file may be redistributed
845 * under the terms of the GNU Public License.
846 */
847
848
849#ifdef __linux__
850
851#ifdef HAVE_LLSEEK
852#include <syscall.h>
853
854#else /* HAVE_LLSEEK */
855
856#if defined(__alpha__) || defined(__ia64__)
857
858#define my_llseek lseek
859
860#else
861#include <asm/unistd.h> /* for __NR__llseek */
862
863static int _llseek (unsigned int, unsigned long,
864 unsigned long, ext2_loff_t *, unsigned int);
865
866#ifdef __NR__llseek
867
868static _syscall5(int,_llseek,unsigned int,f_d,unsigned long,offset_high,
869 unsigned long, offset_low,ext2_loff_t *,result,
870 unsigned int, origin)
871
872#else
873
874/* no __NR__llseek on compilation machine - might give it explicitly */
875static int _llseek (unsigned int f_d, unsigned long oh,
876 unsigned long ol, ext2_loff_t *result,
877 unsigned int origin) {
878 errno = ENOSYS;
879 return -1;
880}
881
882#endif
883
884static ext2_loff_t my_llseek (unsigned int f_d, ext2_loff_t offset,
885 unsigned int origin)
886{
887 ext2_loff_t result;
888 int retval;
889
890 retval = _llseek (f_d, ((unsigned long long) offset) >> 32,
891 ((unsigned long long) offset) & 0xffffffff,
892 &result, origin);
893 return (retval == -1 ? (ext2_loff_t) retval : result);
894}
895
896#endif /* __alpha__ */
897
898#endif /* HAVE_LLSEEK */
899
900static ext2_loff_t ext2_llseek (unsigned int f_d, ext2_loff_t offset,
901 unsigned int origin)
902{
903 ext2_loff_t result;
904 static int do_compat = 0;
905
906 if (!do_compat) {
907 result = my_llseek (f_d, offset, origin);
908 if (!(result == -1 && errno == ENOSYS))
909 return result;
910
911 /*
912 * Just in case this code runs on top of an old kernel
913 * which does not support the llseek system call
914 */
915 do_compat = 1;
916 /*
917 * Now try ordinary lseek.
918 */
919 }
920
921 if ((sizeof(off_t) >= sizeof(ext2_loff_t)) ||
922 (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1))))
923 return lseek(f_d, (off_t) offset, origin);
924
925 errno = EINVAL;
926 return -1;
927}
928
929#else /* !linux */
930
931static ext2_loff_t ext2_llseek (unsigned int f_d, ext2_loff_t offset,
932 unsigned int origin)
933{
934 if ((sizeof(off_t) < sizeof(ext2_loff_t)) &&
935 (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) {
936 errno = EINVAL;
937 return -1;
938 }
939 return lseek (f_d, (off_t) offset, origin);
940}
941
942#endif /* linux */
943
944
945#ifdef CONFIG_FEATURE_OSF_LABEL 841#ifdef CONFIG_FEATURE_OSF_LABEL
946/* 842/*
947 Changes: 843 Changes:
@@ -1466,7 +1362,7 @@ xbsd_write_bootstrap (void)
1466 sector = get_start_sect(xbsd_part); 1362 sector = get_start_sect(xbsd_part);
1467#endif 1363#endif
1468 1364
1469 if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1) 1365 if (lseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
1470 fdisk_fatal (unable_to_seek); 1366 fdisk_fatal (unable_to_seek);
1471 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) 1367 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
1472 fdisk_fatal (unable_to_write); 1368 fdisk_fatal (unable_to_write);
@@ -1634,7 +1530,7 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d)
1634 sector = 0; 1530 sector = 0;
1635#endif 1531#endif
1636 1532
1637 if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1) 1533 if (lseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
1638 fdisk_fatal (unable_to_seek); 1534 fdisk_fatal (unable_to_seek);
1639 if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE)) 1535 if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
1640 fdisk_fatal (unable_to_read); 1536 fdisk_fatal (unable_to_read);
@@ -1680,12 +1576,12 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d)
1680 1576
1681#if defined (__alpha__) && BSD_LABELSECTOR == 0 1577#if defined (__alpha__) && BSD_LABELSECTOR == 0
1682 alpha_bootblock_checksum (disklabelbuffer); 1578 alpha_bootblock_checksum (disklabelbuffer);
1683 if (ext2_llseek (fd, (ext2_loff_t) 0, SEEK_SET) == -1) 1579 if (lseek (fd, (ext2_loff_t) 0, SEEK_SET) == -1)
1684 fdisk_fatal (unable_to_seek); 1580 fdisk_fatal (unable_to_seek);
1685 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) 1581 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
1686 fdisk_fatal (unable_to_write); 1582 fdisk_fatal (unable_to_write);
1687#else 1583#else
1688 if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE + BSD_LABELOFFSET, 1584 if (lseek (fd, (ext2_loff_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
1689 SEEK_SET) == -1) 1585 SEEK_SET) == -1)
1690 fdisk_fatal (unable_to_seek); 1586 fdisk_fatal (unable_to_seek);
1691 if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel))) 1587 if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel)))
@@ -2120,7 +2016,7 @@ sgi_write_table(void)
2120 */ 2016 */
2121 sgiinfo*info = fill_sgiinfo(); /* fills the block appropriately */ 2017 sgiinfo*info = fill_sgiinfo(); /* fills the block appropriately */
2122 int infostartblock = SGI_SSWAP32( sgilabel->directory[0].vol_file_start ); 2018 int infostartblock = SGI_SSWAP32( sgilabel->directory[0].vol_file_start );
2123 if( ext2_llseek(fd, (ext2_loff_t)infostartblock* 2019 if( lseek(fd, (ext2_loff_t)infostartblock*
2124 SECTOR_SIZE, SEEK_SET) < 0 ) 2020 SECTOR_SIZE, SEEK_SET) < 0 )
2125 fdisk_fatal(unable_to_seek); 2021 fdisk_fatal(unable_to_seek);
2126 if( write(fd, info, SECTOR_SIZE) != SECTOR_SIZE ) 2022 if( write(fd, info, SECTOR_SIZE) != SECTOR_SIZE )
@@ -3517,7 +3413,7 @@ static void fdisk_fatal(enum failure why) {
3517static void 3413static void
3518seek_sector(uint secno) { 3414seek_sector(uint secno) {
3519 ext2_loff_t offset = (ext2_loff_t) secno * sector_size; 3415 ext2_loff_t offset = (ext2_loff_t) secno * sector_size;
3520 if (ext2_llseek(fd, offset, SEEK_SET) == (ext2_loff_t) -1) 3416 if (lseek(fd, offset, SEEK_SET) == (ext2_loff_t) -1)
3521 fdisk_fatal(unable_to_seek); 3417 fdisk_fatal(unable_to_seek);
3522} 3418}
3523 3419