Debian Codegraph @

debian/patches/001_fixes

raw
1 Description: debian changes up to 0.9.1.ds1-1
2 Author: Roberto Lumbreras <[email protected]>
3
4 ---
5 See debian/changelog
6
7 Index: lphdisk-0.9.1.ds1/Makefile
8 ===================================================================
9 --- lphdisk-0.9.1.ds1.orig/Makefile 2018-08-09 15:55:14.597953128 +0200
10 +++ lphdisk-0.9.1.ds1/Makefile 2018-08-09 15:55:14.593953107 +0200
11 @@ -4,37 +4,16 @@
12 # lphdisk 0.9.1
13 #
14
15 -INSTALL_PREFIX = /usr/local
16 -
17 -CFLAGS = -g -Wall
18 -LIBS =
19 -
20 -LRMIDIR = lrmi-0.6m
21 +LDLIBS = -lx86
22
23 all: lphdisk
24 -
25 -lphdisk: lphdisk.o lrmi.o
26 - $(CC) $(CFLAGS) -o lphdisk lphdisk.o lrmi.o $(LIBS)
27 -
28 -lphdisk.o: lphdisk.c lrmi.h vbe.h
29 -
30 -lrmi.o:
31 - cd $(LRMIDIR) && $(MAKE) $@
32 - cp $(LRMIDIR)/lrmi.o .
33 -
34 -%.h: $(LRMIDIR)/%.h
35 - cp $^ $@
36 -
37 -install: all
38 - install -m 755 lphdisk $(INSTALL_PREFIX)/sbin
39 - install -m 644 lphdisk.8 $(INSTALL_PREFIX)/man/man8
40 +lphdisk: lphdisk.o
41 +lphdisk.o: lphdisk.c vbe.h
42
43 clean:
44 - cd $(LRMIDIR) && $(MAKE) $@
45 - rm -f *.o lrmi.h vbe.h
46 + rm -f *.o
47 + rm -f lphdisk
48
49 distclean: clean
50 - cd $(LRMIDIR) && $(MAKE) $@
51 - rm -f lphdisk
52
53 .PHONY: all install clean distclean
54 Index: lphdisk-0.9.1.ds1/lphdisk.c
55 ===================================================================
56 --- lphdisk-0.9.1.ds1.orig/lphdisk.c 2018-08-09 15:55:14.597953128 +0200
57 +++ lphdisk-0.9.1.ds1/lphdisk.c 2018-08-09 15:55:46.426120843 +0200
58 @@ -19,8 +19,10 @@
59 Be careful!
60 */
61
62 +#define _LARGEFILE64_SOURCE
63 #include <stdio.h>
64 #include <stdlib.h>
65 +#include <sys/sysmacros.h>
66 #include <unistd.h>
67 #include <string.h>
68 #include <stdarg.h>
69 @@ -29,7 +31,7 @@
70 #include <fcntl.h>
71 #include <sys/stat.h>
72 #include <sys/io.h>
73 -#include "lrmi.h"
74 +#include <libx86.h>
75 #include "vbe.h"
76
77 /* General Program Defines: */
78 @@ -100,58 +102,6 @@
79 /* General Purpose Utility Routines */
80 /*****************************************************************************/
81
82 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
83 -/* The following is a hack to take advantage of the ext2 "_llseek" system */
84 -/* call to do seeks to "long long" offsets under linux (this is needed to */
85 -/* seek to sectors beyond 4194303 (2GB)). This isn't directly supported by */
86 -/* glibc, so we need to make our own interface function for it. We should */
87 -/* be able to get the _NR__llseek define from linux/unistd.h. From this we */
88 -/* can construct a wrapper to perform the right system call. */
89 -
90 -#include <linux/unistd.h> /* for __NR__llseek */
91 -
92 -typedef long long lloff_t;
93 -
94 -#ifdef __NR__llseek
95 -
96 -static _syscall5(int,_llseek, unsigned int,fd, unsigned long,offset_high,
97 - unsigned long,offset_low, lloff_t *,result,
98 - unsigned int,origin)
99 -
100 -lloff_t llseek (unsigned int fd, lloff_t offset, unsigned int origin) {
101 - lloff_t result;
102 - int retval;
103 -
104 - retval = _llseek (fd, ((unsigned long long) offset) >> 32,
105 - ((unsigned long long) offset) & 0xffffffff,
106 - &result, origin);
107 - return (retval == -1 ? (lloff_t) retval : result);
108 -}
109 -
110 -#else /* __NR__llseek */
111 -
112 -/* Somehow, __NR__llseek wasn't in linux/unistd.h. This shouldn't ever */
113 -/* happen, but better safe than sorry.. The best we can do is emulate it */
114 -/* with lseek, and hope we don't get an offset that's too large (throw an */
115 -/* error if we do) */
116 -
117 -lloff_t llseek (unsigned int fd, lloff_t offset, unsigned int origin) {
118 - off_t offt_offset = (off_t) offset;
119 -
120 - if ((lloff_t)offt_offset != offset) {
121 - /* converting to off_t and back yields different result, indicating an */
122 - /* overflow.. */
123 - errno = EINVAL;
124 - return -1;
125 - } else {
126 - return lseek(fd, offt_offset, origin);
127 - }
128 -}
129 -
130 -#endif /* __NR__llseek */
131 -
132 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
133 -
134 #define get16(p) get_int_le(p,2)
135 #define get32(p) get_int_le(p,4)
136
137 @@ -189,9 +139,9 @@
138 /* success, nonzero on error. */
139
140 int seek_sector (int fd, size_t secno) {
141 - lloff_t offset = (lloff_t) secno * SECTOR_SIZE;
142 + off64_t offset = (off64_t) secno * SECTOR_SIZE;
143
144 - if (llseek(fd, offset, SEEK_SET) == (lloff_t) -1)
145 + if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1)
146 return -1;
147
148 return 0;
149 @@ -556,25 +506,29 @@
150
151 int meminfo_physmem(void) {
152 FILE *f;
153 - unsigned int size;
154 + unsigned int size = 0;
155 int ramsize;
156 + char s[128];
157
158 if (!(f = fopen(meminfo_filename, "r"))) {
159 debug("Unable to open %s: %s\n", meminfo_filename, strerror(errno));
160 return 0;
161 }
162 - fscanf(f, "%*[^\n]\n"); /* Read the header line and discard it */
163
164 - if (fscanf(f, "Mem: %u", &size) != 1) {
165 + while (fgets(s, sizeof(s), f)) {
166 + if (sscanf(s, "MemTotal: %u", &size) == 1) {
167 + break;
168 + }
169 + }
170 + if (size == 0) {
171 debug("Parse of %s failed.\n", meminfo_filename);
172 return 0;
173 }
174 fclose(f);
175
176 - /* convert to KB and then round up to the next power of 2 (since RAM */
177 + /* size is in KB and then round up to the next power of 2 (since RAM */
178 /* sizes don't come in anything else, so this should correct for the */
179 /* kernel size, etc) */
180 - size >>= 10;
181 debug("%s reports memory size of %d KB", meminfo_filename, size);
182 for (ramsize = 1; size; size >>= 1) ramsize <<= 1;
183
184 @@ -718,22 +672,22 @@
185 {"force", 0, 0, 'f'},
186 {0,0,0,0}};
187
188 -const char usage_string[] = "\
189 -Usage: %1$s [options] [device]
190 -Prepare a hibernation partition for APM suspend-to-disk.
191 -
192 -options:
193 - -h, --help Display brief usage and option information (this screen)
194 - -p, --probeonly Only calculate and display required size, do not format
195 - -q, --quiet Turn off informational messages, useful for scripts
196 - -d, --debug Turn on (verbose) debugging messages
197 - -n, --nowrite Do not actually write to the disk
198 - -f, --force **DANGEROUS** Format without regard to potential problems
199 -
200 -'device' should be a raw disk device (not a partition). The default device
201 -is /dev/hda.
202 -
203 -(%2$s)\n\n";
204 +const char usage_string[] = ""
205 +"Usage: %1$s [options] [device]\n"
206 +"Prepare a hibernation partition for APM suspend-to-disk.\n"
207 +"\n"
208 +"options:\n"
209 +" -h, --help Display brief usage and option information (this screen)\n"
210 +" -p, --probeonly Only calculate and display required size, do not format\n"
211 +" -q, --quiet Turn off informational messages, useful for scripts\n"
212 +" -d, --debug Turn on (verbose) debugging messages\n"
213 +" -n, --nowrite Do not actually write to the disk\n"
214 +" -f, --force **DANGEROUS** Format without regard to potential problems\n"
215 +"\n"
216 +"'device' should be a raw disk device (not a partition). The default device\n"
217 +"is /dev/hda.\n"
218 +"\n"
219 +"(%2$s)\n\n";
220
221 void print_usage (void) {
222 char *progname = rindex(argv0, '/');
223 @@ -750,7 +704,7 @@
224 dev_t dev;
225 int partition;
226 int ramsize, vramsize, required_size;
227 - size_t required_sectors;
228 + size_t required_sectors = 0;
229
230 argv0 = argv[0];
231
232 @@ -821,9 +775,9 @@
233 }
234
235 if (!required_size) {
236 - if (!quiet_flag) printf("Reccomended partition size is unknown.\n");
237 + if (!quiet_flag) printf("Recommended partition size is unknown.\n");
238 } else {
239 - if (!quiet_flag) printf("Reccomended partition size is %d MB"
240 + if (!quiet_flag) printf("Recommended partition size is %d MB"
241 " (%d sectors)\n", ((required_size+1023) >> 10),
242 required_sectors);
243 }
244 @@ -923,7 +877,7 @@
245
246 if ((pi[partition-1].size < required_sectors) && !quiet_flag) {
247 fprintf(stderr, "Warning: hibernate partition size (%d) is smaller than"
248 - " reccomended size (%d).\n", pi[partition-1].size,
249 + " recommended size (%d).\n", pi[partition-1].size,
250 required_sectors);
251 }
252