added devmapper, cryptsetup and libpopt
[hdw-linux/hdw-linux.git] / packages / base / util-linux / lseek.patch
1 --- util-linux-2.12r.orig/fdisk/Makefile        2004-09-06 20:28:58.000000000 +0000
2 +++ util-linux-2.12r/fdisk/Makefile     2006-07-08 15:40:57.140375072 +0000
3 @@ -39,7 +39,7 @@ else
4  endif
5  endif
6  
7 -cfdisk: cfdisk.o llseek.o disksize.o i386_sys_types.o $(LIB)/xstrncpy.o
8 +cfdisk: cfdisk.o disksize.o i386_sys_types.o $(LIB)/xstrncpy.o
9  ifeq "$(HAVE_SLANG)" "yes"
10         $(CC) $(LDFLAGS) $^ -o $@ $(LIBSLANG)
11  else
12 @@ -55,7 +55,7 @@ activate: sfdisk
13         rm -f activate
14         ln -s sfdisk activate
15  
16 -fdisk: fdisk.o llseek.o disksize.o fdiskbsdlabel.o fdisksgilabel.o \
17 +fdisk: fdisk.o disksize.o fdiskbsdlabel.o fdisksgilabel.o \
18         fdisksunlabel.o fdiskaixlabel.o i386_sys_types.o partname.o
19  fdisk.o: fdisk.c fdisk.h
20  fdiskbsdlabel.o: fdiskbsdlabel.c fdisk.h fdiskbsdlabel.h
21 --- util-linux-2.12r.orig/fdisk/cfdisk.c        2005-09-09 21:44:57.000000000 +0000
22 +++ util-linux-2.12r/fdisk/cfdisk.c     2006-07-08 15:40:23.458901045 +0000
23 @@ -84,9 +84,6 @@
24  #include "xstrncpy.h"
25  #include "common.h"
26  
27 -extern long long ext2_llseek(unsigned int fd, long long offset,
28 -                            unsigned int origin);
29 -
30  #define VERSION UTIL_LINUX_VERSION
31  
32  #define DEFAULT_DEVICE "/dev/hda"
33 @@ -552,7 +549,7 @@ die_x(int ret) {
34  
35  static void
36  read_sector(char *buffer, long long sect_num) {
37 -    if (ext2_llseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0)
38 +    if (lseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0)
39         fatal(_("Cannot seek on disk drive"), 2);
40      if (read(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE)
41         fatal(_("Cannot read disk drive"), 2);
42 @@ -560,7 +557,7 @@ read_sector(char *buffer, long long sect
43  
44  static void
45  write_sector(char *buffer, long long sect_num) {
46 -    if (ext2_llseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0)
47 +    if (lseek(fd, sect_num*SECTOR_SIZE, SEEK_SET) < 0)
48         fatal(_("Cannot seek on disk drive"), 2);
49      if (write(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE)
50         fatal(_("Cannot write disk drive"), 2);
51 @@ -587,7 +584,7 @@ get_dos_label(int i) {
52         long long offset;
53  
54         offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE;
55 -       if (ext2_llseek(fd, offset, SEEK_SET) == offset
56 +       if (lseek(fd, offset, SEEK_SET) == offset
57             && read(fd, &sector, sizeof(sector)) == sizeof(sector)) {
58                 dos_copy_to_info(p_info[i].ostype, OSTYPESZ,
59                                  sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ);
60 @@ -672,7 +669,7 @@ get_linux_label(int i) {
61  
62         offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE
63                 + 1024;
64 -       if (ext2_llseek(fd, offset, SEEK_SET) == offset
65 +       if (lseek(fd, offset, SEEK_SET) == offset
66             && read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb)
67             && e2fsb.s_magic[0] + (e2fsb.s_magic[1]<<8) == EXT2_SUPER_MAGIC) {
68                 label = e2fsb.s_volume_name;
69 @@ -688,7 +685,7 @@ get_linux_label(int i) {
70         }
71  
72         offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE + 0;
73 -       if (ext2_llseek(fd, offset, SEEK_SET) == offset
74 +       if (lseek(fd, offset, SEEK_SET) == offset
75             && read(fd, &xfsb, sizeof(xfsb)) == sizeof(xfsb)
76             && !strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4)) {
77                 label = xfsb.s_fname;
78 @@ -702,7 +699,7 @@ get_linux_label(int i) {
79         /* jfs? */
80         offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE
81                 + JFS_SUPER1_OFF;
82 -       if (ext2_llseek(fd, offset, SEEK_SET) == offset
83 +       if (lseek(fd, offset, SEEK_SET) == offset
84             && read(fd, &jfsb, sizeof(jfsb)) == sizeof(jfsb)
85             && !strncmp(jfsb.s_magic, JFS_MAGIC, strlen(JFS_MAGIC))) {
86                 label = jfsb.s_label;
87 @@ -716,7 +713,7 @@ get_linux_label(int i) {
88         /* reiserfs? */
89         offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE
90                 + REISERFS_DISK_OFFSET_IN_BYTES;
91 -       if (ext2_llseek(fd, offset, SEEK_SET) == offset
92 +       if (lseek(fd, offset, SEEK_SET) == offset
93             && read(fd, &reiserfsb, sizeof(reiserfsb)) == sizeof(reiserfsb)
94             && has_reiserfs_magic_string(&reiserfsb, &reiserfs_is_3_6)) {
95                 if (reiserfs_is_3_6) {
96 @@ -1860,7 +1857,7 @@ write_part_table(void) {
97  
98          while (!done) {
99               mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X,
100 -                      _("Are you sure you want write the partition table "
101 +                      _("Are you sure you want to write the partition table "
102                        "to disk? (yes or no): "));
103               len = get_string(response, LINE_LENGTH, NULL);
104               clear_warning();
105 --- util-linux-2.12r.orig/fdisk/fdisk.c 2004-12-18 02:00:31.000000000 +0000
106 +++ util-linux-2.12r/fdisk/fdisk.c      2006-07-08 15:40:23.461899841 +0000
107 @@ -239,8 +239,8 @@ void fatal(enum failure why) {
108  
109  static void
110  seek_sector(int fd, unsigned int secno) {
111 -       long long offset = (long long) secno * sector_size;
112 -       if (ext2_llseek(fd, offset, SEEK_SET) == (long long) -1)
113 +       off_t offset = (off_t) secno * sector_size;
114 +       if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
115                 fatal(unable_to_seek);
116  }
117  
118 --- util-linux-2.12r.orig/fdisk/fdisk.h 2004-12-15 18:19:06.000000000 +0000
119 +++ util-linux-2.12r/fdisk/fdisk.h      2006-07-08 15:40:23.462899439 +0000
120 @@ -26,9 +26,6 @@
121  #define cround(n)      (display_in_cyl_units ? ((n)/units_per_sector)+1 : (n))
122  #define scround(x)     (((x)+units_per_sector-1)/units_per_sector)
123  
124 -extern long long ext2_llseek(unsigned int fd, long long offset,
125 -                            unsigned int origin);
126 -
127  #if defined(__GNUC__) && (defined(__arm__) || defined(__alpha__))
128  # define PACKED __attribute__ ((packed))
129  #else
130 --- util-linux-2.12r.orig/fdisk/fdiskbsdlabel.c 2003-07-13 21:12:47.000000000 +0000
131 +++ util-linux-2.12r/fdisk/fdiskbsdlabel.c      2006-07-08 15:40:23.463899038 +0000
132 @@ -566,7 +566,7 @@ xbsd_write_bootstrap (void)
133    sector = get_start_sect(xbsd_part);
134  #endif
135  
136 -  if (ext2_llseek (fd, (long long) sector * SECTOR_SIZE, SEEK_SET) == -1)
137 +  if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
138      fatal (unable_to_seek);
139    if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
140      fatal (unable_to_write);
141 @@ -735,7 +735,7 @@ xbsd_readlabel (struct partition *p, str
142         sector = 0;
143  #endif
144  
145 -       if (ext2_llseek (fd, (long long) sector * SECTOR_SIZE, SEEK_SET) == -1)
146 +       if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
147                 fatal (unable_to_seek);
148         if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
149                 fatal (unable_to_read);
150 @@ -781,12 +781,12 @@ xbsd_writelabel (struct partition *p, st
151  
152  #if defined (__alpha__) && BSD_LABELSECTOR == 0
153    alpha_bootblock_checksum (disklabelbuffer);
154 -  if (ext2_llseek (fd, (long long) 0, SEEK_SET) == -1)
155 +  if (lseek (fd, (off_t) 0, SEEK_SET) == -1)
156      fatal (unable_to_seek);
157    if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
158      fatal (unable_to_write);
159  #else
160 -  if (ext2_llseek (fd, (long long) sector * SECTOR_SIZE + BSD_LABELOFFSET,
161 +  if (lseek (fd, (off_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
162                    SEEK_SET) == -1)
163      fatal (unable_to_seek);
164    if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel)))
165 --- util-linux-2.12r.orig/fdisk/fdisksgilabel.c 2004-12-18 01:53:45.000000000 +0000
166 +++ util-linux-2.12r/fdisk/fdisksgilabel.c      2006-07-08 15:40:23.464898637 +0000
167 @@ -379,7 +379,7 @@ sgi_write_table(void) {
168                  */
169                 sgiinfo *info = fill_sgiinfo();
170                 int infostartblock = SSWAP32(sgilabel->directory[0].vol_file_start);
171 -               if (ext2_llseek(fd, (long long)infostartblock*
172 +               if (lseek(fd, (off_t) infostartblock*
173                                 SECTOR_SIZE, SEEK_SET) < 0)
174                         fatal(unable_to_seek);
175                 if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE)
176 --- util-linux-2.12r.orig/fdisk/sfdisk.c        2005-01-04 22:31:57.000000000 +0000
177 +++ util-linux-2.12r/fdisk/sfdisk.c     2006-07-08 15:40:23.467897432 +0000
178 @@ -164,36 +164,17 @@ fatal(char *s, ...) {
179  /*
180   * sseek: seek to specified sector - return 0 on failure
181   *
182 - * For >4GB disks lseek needs a > 32bit arg, and we have to use llseek.
183 - * On the other hand, a 32 bit sector number is OK until 2TB.
184 - * The routines _llseek and sseek below are the only ones that
185 - * know about the loff_t type.
186 - *
187   * Note: we use 512-byte sectors here, irrespective of the hardware ss.
188   */
189 -#undef use_lseek
190 -#if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (__s390x__)
191 -#define use_lseek
192 -#endif
193 -
194 -#ifndef use_lseek
195 -static __attribute__used
196 -_syscall5(int,  _llseek,  unsigned int,  fd, ulong, hi, ulong, lo,
197 -       loff_t *, res, unsigned int, wh);
198 -#endif
199  
200  static int
201  sseek(char *dev, unsigned int fd, unsigned long s) {
202 -    loff_t in, out;
203 -    in = ((loff_t) s << 9);
204 +    off_t in, out;
205 +    in = ((off_t) s << 9);
206      out = 1;
207  
208 -#ifndef use_lseek
209 -    if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0) {
210 -#else
211      if ((out = lseek(fd, in, SEEK_SET)) != in) {
212 -#endif
213 -       perror("llseek");
214 +       perror("lseek");
215         error(_("seek error on %s - cannot seek to %lu\n"), dev, s);
216         return 0;
217      }
218 --- util-linux-2.12r.orig/partx/partx.c 2004-08-23 20:13:27.000000000 +0000
219 +++ util-linux-2.12r/partx/partx.c      2006-07-08 15:40:23.469896630 +0000
220 @@ -330,34 +330,15 @@ xmalloc (size_t size) {
221         return t;
222  }
223  
224 -/*
225 - * sseek: seek to specified sector
226 - */
227 -#if !defined (__alpha__) && !defined (__ia64__) && !defined (__s390x__) && !defined(__x86_64__)
228 -#define NEED__llseek
229 -#endif
230 -
231 -#ifdef NEED__llseek
232 -#include <linux/unistd.h>       /* _syscall */
233 -static
234 -_syscall5(int,  _llseek,  uint,  fd, ulong, hi, ulong, lo,
235 -         long long *, res, uint, wh);
236 -#endif
237 -
238  static int
239  sseek(int fd, unsigned int secnr) {
240         long long in, out;
241         in = ((long long) secnr << 9);
242         out = 1;
243  
244 -#ifdef NEED__llseek
245 -       if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0
246 -           || out != in)
247 -#else
248         if ((out = lseek(fd, in, SEEK_SET)) != in)
249 -#endif
250         {
251 -               fprintf(stderr, "llseek error\n");
252 +               fprintf(stderr, "lseek error\n");
253                 return -1;
254         }
255         return 0;