summaryrefslogtreecommitdiffstats
path: root/fdisk
diff options
context:
space:
mode:
Diffstat (limited to 'fdisk')
-rw-r--r--fdisk/Makefile.am6
-rw-r--r--fdisk/Makefile.in25
-rw-r--r--fdisk/cfdisk.c19
-rw-r--r--fdisk/fdisk.c4
-rw-r--r--fdisk/fdisk.h3
-rw-r--r--fdisk/fdiskbsdlabel.c8
-rw-r--r--fdisk/fdisksgilabel.c2
-rw-r--r--fdisk/llseek.c110
-rw-r--r--fdisk/sfdisk.c25
9 files changed, 31 insertions, 171 deletions
diff --git a/fdisk/Makefile.am b/fdisk/Makefile.am
index 8fa42965a..c4528d0e3 100644
--- a/fdisk/Makefile.am
+++ b/fdisk/Makefile.am
@@ -4,7 +4,7 @@ if !M68K
sbin_PROGRAMS = fdisk
man_MANS = fdisk.8
-fdisk_SOURCES = fdisk.c llseek.c disksize.c fdiskbsdlabel.c fdisksgilabel.c \
+fdisk_SOURCES = fdisk.c disksize.c fdiskbsdlabel.c fdisksgilabel.c \
fdisksunlabel.c fdiskaixlabel.c i386_sys_types.c partname.c
if !SPARC
@@ -16,13 +16,13 @@ sfdisk_SOURCES = sfdisk.c disksize.c i386_sys_types.c partname.c
if USE_SLANG
sbin_PROGRAMS += cfdisk
man_MANS += cfdisk.8
-cfdisk_SOURCES = cfdisk.c llseek.c disksize.c i386_sys_types.c
+cfdisk_SOURCES = cfdisk.c disksize.c i386_sys_types.c
cfdisk_LDADD = -lslang
else
if HAVE_NCURSES
sbin_PROGRAMS += cfdisk
man_MANS += cfdisk.8
-cfdisk_SOURCES = cfdisk.c llseek.c disksize.c i386_sys_types.c
+cfdisk_SOURCES = cfdisk.c disksize.c i386_sys_types.c
cfdisk_LDADD = -lncurses
endif
endif
diff --git a/fdisk/Makefile.in b/fdisk/Makefile.in
index 4f6a5f50c..933db7317 100644
--- a/fdisk/Makefile.in
+++ b/fdisk/Makefile.in
@@ -65,27 +65,23 @@ CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"
sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(sbin_PROGRAMS)
-am__cfdisk_SOURCES_DIST = cfdisk.c llseek.c disksize.c \
- i386_sys_types.c
+am__cfdisk_SOURCES_DIST = cfdisk.c disksize.c i386_sys_types.c
@HAVE_NCURSES_TRUE@@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_FALSE@am_cfdisk_OBJECTS = cfdisk.$(OBJEXT) \
-@HAVE_NCURSES_TRUE@@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_FALSE@ llseek.$(OBJEXT) \
@HAVE_NCURSES_TRUE@@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_FALSE@ disksize.$(OBJEXT) \
@HAVE_NCURSES_TRUE@@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_FALSE@ i386_sys_types.$(OBJEXT)
@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@am_cfdisk_OBJECTS = \
@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@ cfdisk.$(OBJEXT) \
-@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@ llseek.$(OBJEXT) \
@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@ disksize.$(OBJEXT) \
@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@ i386_sys_types.$(OBJEXT)
cfdisk_OBJECTS = $(am_cfdisk_OBJECTS)
cfdisk_DEPENDENCIES =
-am__fdisk_SOURCES_DIST = fdisk.c llseek.c disksize.c fdiskbsdlabel.c \
+am__fdisk_SOURCES_DIST = fdisk.c disksize.c fdiskbsdlabel.c \
fdisksgilabel.c fdisksunlabel.c fdiskaixlabel.c \
i386_sys_types.c partname.c
-@M68K_FALSE@am_fdisk_OBJECTS = fdisk.$(OBJEXT) llseek.$(OBJEXT) \
-@M68K_FALSE@ disksize.$(OBJEXT) fdiskbsdlabel.$(OBJEXT) \
-@M68K_FALSE@ fdisksgilabel.$(OBJEXT) fdisksunlabel.$(OBJEXT) \
-@M68K_FALSE@ fdiskaixlabel.$(OBJEXT) i386_sys_types.$(OBJEXT) \
-@M68K_FALSE@ partname.$(OBJEXT)
+@M68K_FALSE@am_fdisk_OBJECTS = fdisk.$(OBJEXT) disksize.$(OBJEXT) \
+@M68K_FALSE@ fdiskbsdlabel.$(OBJEXT) fdisksgilabel.$(OBJEXT) \
+@M68K_FALSE@ fdisksunlabel.$(OBJEXT) fdiskaixlabel.$(OBJEXT) \
+@M68K_FALSE@ i386_sys_types.$(OBJEXT) partname.$(OBJEXT)
fdisk_OBJECTS = $(am_fdisk_OBJECTS)
fdisk_LDADD = $(LDADD)
am__sfdisk_SOURCES_DIST = sfdisk.c disksize.c i386_sys_types.c \
@@ -270,16 +266,16 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
usrbinexecdir = $(prefix)/usr/bin
usrsbinexecdir = $(prefix)/usr/sbin
-AM_CPPFLAGS = -include $(top_srcdir)/config.h -I$(top_srcdir)/include
+AM_CPPFLAGS = -include $(top_builddir)/config.h -I$(top_srcdir)/include
DEFAULT_INCLUDES =
@M68K_FALSE@man_MANS = fdisk.8 $(am__append_2) $(am__append_4) \
@M68K_FALSE@ $(am__append_6)
-@M68K_FALSE@fdisk_SOURCES = fdisk.c llseek.c disksize.c fdiskbsdlabel.c fdisksgilabel.c \
+@M68K_FALSE@fdisk_SOURCES = fdisk.c disksize.c fdiskbsdlabel.c fdisksgilabel.c \
@M68K_FALSE@ fdisksunlabel.c fdiskaixlabel.c i386_sys_types.c partname.c
@M68K_FALSE@@SPARC_FALSE@sfdisk_SOURCES = sfdisk.c disksize.c i386_sys_types.c partname.c
-@HAVE_NCURSES_TRUE@@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_FALSE@cfdisk_SOURCES = cfdisk.c llseek.c disksize.c i386_sys_types.c
-@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@cfdisk_SOURCES = cfdisk.c llseek.c disksize.c i386_sys_types.c
+@HAVE_NCURSES_TRUE@@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_FALSE@cfdisk_SOURCES = cfdisk.c disksize.c i386_sys_types.c
+@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@cfdisk_SOURCES = cfdisk.c disksize.c i386_sys_types.c
@HAVE_NCURSES_TRUE@@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_FALSE@cfdisk_LDADD = -lncurses
@M68K_FALSE@@SPARC_FALSE@@USE_SLANG_TRUE@cfdisk_LDADD = -lslang
all: all-am
@@ -362,7 +358,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdisksgilabel.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdisksunlabel.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_sys_types.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/llseek.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/partname.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfdisk.Po@am__quote@
diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
index e3616774e..f7ecf529c 100644
--- a/fdisk/cfdisk.c
+++ b/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 DEFAULT_DEVICE "/dev/hda"
#define ALTERNATE_DEVICE "/dev/sda"
@@ -550,7 +547,7 @@ die_x(int ret) {
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);
@@ -558,7 +555,7 @@ read_sector(char *buffer, long long sect_num) {
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);
@@ -585,7 +582,7 @@ get_dos_label(int i) {
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);
@@ -670,7 +667,7 @@ get_linux_label(int i) {
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;
@@ -686,7 +683,7 @@ get_linux_label(int i) {
}
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;
@@ -700,7 +697,7 @@ get_linux_label(int i) {
/* 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;
@@ -714,7 +711,7 @@ get_linux_label(int i) {
/* 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) {
@@ -1858,7 +1855,7 @@ write_part_table(void) {
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();
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index b7894e8b5..f83104977 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -241,8 +241,8 @@ void fatal(enum failure why) {
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);
}
diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h
index 13c07147b..024495be3 100644
--- a/fdisk/fdisk.h
+++ b/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
diff --git a/fdisk/fdiskbsdlabel.c b/fdisk/fdiskbsdlabel.c
index fe2039115..01912ab52 100644
--- a/fdisk/fdiskbsdlabel.c
+++ b/fdisk/fdiskbsdlabel.c
@@ -566,7 +566,7 @@ xbsd_write_bootstrap (void)
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 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d)
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 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d)
#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)))
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c
index b46515e28..487a92f92 100644
--- a/fdisk/fdisksgilabel.c
+++ b/fdisk/fdisksgilabel.c
@@ -379,7 +379,7 @@ sgi_write_table(void) {
*/
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)
diff --git a/fdisk/llseek.c b/fdisk/llseek.c
deleted file mode 100644
index e2e6427cb..000000000
--- a/fdisk/llseek.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * llseek.c -- stub calling the llseek system call
- *
- * Copyright (C) 1994 Remy Card. This file may be redistributed
- * under the terms of the GNU Public License.
- */
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-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
-
-/* no __NR__llseek on compilation machine - might give it explicitly */
-static int _llseek (unsigned int fd, unsigned long oh,
- unsigned long ol, long long *result,
- unsigned int origin) {
- errno = ENOSYS;
- return -1;
-}
-
-#endif
-
-static long long my_llseek (unsigned int fd, long long offset,
- unsigned int origin)
-{
- long long result;
- int retval;
-
- retval = _llseek (fd, ((unsigned long long) offset) >> 32,
- ((unsigned long long) offset) & 0xffffffff,
- &result, origin);
- return (retval == -1 ? (long long) retval : result);
-}
-
-#endif /* __alpha__ */
-
-#endif /* HAVE_LLSEEK */
-
-long long ext2_llseek (unsigned int fd, long long offset,
- unsigned int origin)
-{
- long long result;
- static int do_compat = 0;
-
- if (!do_compat) {
- result = my_llseek (fd, offset, origin);
- if (!(result == -1 && errno == ENOSYS))
- return result;
-
- /*
- * Just in case this code runs on top of an old kernel
- * which does not support the llseek system call
- */
- do_compat = 1;
- /*
- * Now try ordinary lseek.
- */
- }
-
- if ((sizeof(off_t) >= sizeof(long long)) ||
- (offset < ((long long) 1 << ((sizeof(off_t)*8) -1))))
- return lseek(fd, (off_t) offset, origin);
-
- errno = EINVAL;
- return -1;
-}
-
-#else /* !linux */
-
-long long ext2_llseek (unsigned int fd, long long offset,
- unsigned int origin)
-{
- if ((sizeof(off_t) < sizeof(long long)) &&
- (offset >= ((long long) 1 << ((sizeof(off_t)*8) -1)))) {
- errno = EINVAL;
- return -1;
- }
- return lseek (fd, (off_t) offset, origin);
-}
-
-#endif /* linux */
-
-
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index b859ef565..6e9e5697a 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -162,36 +162,17 @@ fatal(char *s, ...) {
/*
* 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;
}