summaryrefslogtreecommitdiff
path: root/sysutils/same/patches/patch-ac
blob: c446f9489e9b2643873d2471030479b62c0ef4a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
$NetBSD: patch-ac,v 1.4 2017/02/18 13:57:37 joerg Exp $

--- same.c.orig	2004-07-16 17:30:01.000000000 +0000
+++ same.c
@@ -106,10 +106,9 @@
  * - There is a 1024 (BUFSIZE) character limit to pathnames when using 
  *   symlinks.
  *
- * - The same source is not exactly 32kbytes long.  However this comment 
- *   seems to fix that.
  * */
 
+#define _FILE_OFFSET_BITS	64
 
 #include <assert.h>
 #include <stdio.h>
@@ -123,16 +122,8 @@
 #include <sys/times.h>
 #include <zlib.h>
 #include <limits.h>
-
-#define __USE_LARGEFILE64
 #include <sys/stat.h>
 
-#if 1
-/* Why the *&^#$ doesn't sys/stat define this??? */
-extern int lstat64 (__const char *__restrict __file,
-                    struct stat64 *__restrict __buf) __THROW;
-#endif
-
 #ifdef __linux__
 #include <asm/page.h>
 #else /* !__linux__ */
@@ -157,6 +148,11 @@ extern int lstat64 (__const char *__rest
 #define true		1
 #define false		0
 
+#if defined(__GNUC__)
+#  define attribute_unused __attribute__((__unused__))
+#else
+#  define attribute_unused /**/
+#endif
 
 static volatile int stop;
 static volatile int doing_input;
@@ -184,7 +180,7 @@ static const char *o_cache;
 
 struct name_entry {
     struct name_entry *next;
-    char name[0];
+    char name[1];
 };
 
 #define F_CRC_VALID		(1 << 0)
@@ -196,7 +192,7 @@ struct inode_entry {
     struct name_entry *names;
     int flags;			/* See F_* definitions above */
     /* The two fields below may have been read from the cache */
-    loff_t size;
+    off_t size;
     unsigned int crc;		/* valid if flags & F_CRC_VALID only */
     /* The four fields below are valid if flags & F_STAT_VALID only */
     dev_t device;
@@ -265,7 +261,7 @@ static void dump_inode_entry(const struc
 static void dump_hashtable(void);
 static void load_cache(void);
 static void save_cache(void);
-static void save_entry(gzFile *out, const struct inode_entry *entry);
+static void save_entry(gzFile out, const struct inode_entry *entry);
 static void *p_malloc(unsigned int hash, size_t size);
 static struct inode_entry *alloc_inode_entry(unsigned int hash, int is_new);
 static void delete_inode_entry(struct inode_entry *entry);
@@ -288,7 +284,7 @@ static void read_list(void);
 static const char *get_fname(void);
 static struct inode_entry *get_entry(void);
 static int __get_stat(struct inode_entry *entry);
-static unsigned int calc_hash(const struct stat64 *sb);
+static unsigned int calc_hash(const struct stat *sb);
 static int __get_crc(struct inode_entry *entry);
 static int cmp(const struct inode_entry *entry1,
 	       const struct inode_entry *entry2);
@@ -379,7 +375,7 @@ static void dump_inode_entry(const struc
 
     printf("%sentry %p size %lu crc %08x device %lx inode %lx nlink %d uid "
 	   "%lx\n",
-	   indent, entry, (unsigned long)entry->size, entry->crc,
+	   indent, (void *)entry, (unsigned long)entry->size, entry->crc,
 	   (unsigned long)entry->device, (unsigned long)entry->inode,
 	   entry->nlink, (unsigned long)entry->uid);
     for (names = entry->names; names; names = names->next)
@@ -426,10 +422,10 @@ static inline int is_new(const struct in
 static void load_cache(void)
 {
     static char buf[BUFSIZE];
-    gzFile *in;
+    gzFile in;
     unsigned long line = 0;
     char *s;
-    loff_t size;
+    off_t size;
     unsigned int crc;
     const char *name;
     unsigned int hash = 0;
@@ -505,7 +501,7 @@ static void *Malloc (size_t size)
 static void save_cache(void)
 {
     struct stat sb;
-    gzFile *out;
+    gzFile out;
     unsigned int i;
     struct inode_entry *entry;
     char backup[PATH_MAX+1], tmpname[PATH_MAX+1];
@@ -563,7 +559,7 @@ static void save_cache(void)
      *  Save a cache entry
      */
 
-static void save_entry(gzFile *out, const struct inode_entry *entry)
+static void save_entry(gzFile out, const struct inode_entry *entry)
 {
     const struct name_entry *names;
 
@@ -587,7 +583,7 @@ static void *p_malloc(unsigned int hash,
     void *data;
 
     if (size > sizeof(pool->data)) {
-	fprintf(stderr, "Warning: p_malloc() of size %u\n", size);
+	fprintf(stderr, "Warning: p_malloc() of size %zu\n", size);
 	return malloc(size);
     }
 
@@ -659,7 +655,7 @@ static struct name_entry *alloc_name_ent
     return entry;
 }
 
-static void delete_name_entry(struct name_entry *entry __attribute__((__unused__)))
+static void delete_name_entry(struct name_entry *entry attribute_unused)
 {
     /*
      *  We don't free names allocated from the pool
@@ -1168,7 +1164,7 @@ static struct inode_entry *get_entry(voi
 {
     const char *buf;
     struct inode_entry *entry;
-    struct stat64 sb;
+    struct stat sb;
     unsigned int hash;
 
     do {
@@ -1176,7 +1172,7 @@ static struct inode_entry *get_entry(voi
 	if (buf == NULL)
 	    return NULL;
 	stat_stat++;
-	if (lstat64(buf, &sb) < 0) {
+	if (lstat(buf, &sb) < 0) {
 	    fprintf(stderr, "stat %s: %s\n", buf, strerror(errno));
 	    exit(1);
 	}
@@ -1204,13 +1200,13 @@ static struct inode_entry *get_entry(voi
 
 static int __get_stat(struct inode_entry *entry)
 {
-    struct stat64 sb;
+    struct stat sb;
     struct name_entry *name;
 
     /* Loop until we find a file that does exist */
     while ((name = entry->names) != 0) {
 	stat_stat++;
-	if (lstat64(name->name, &sb) < 0)
+	if (lstat(name->name, &sb) < 0)
 	    fprintf(stderr, "stat %s: %s\n", name->name, strerror(errno));
 	else if (S_ISREG(sb.st_mode)) {
 	    entry->device = sb.st_dev;
@@ -1231,7 +1227,7 @@ static int __get_stat(struct inode_entry
      *  Calculate the Hash Value for an Inode Entry
      */
 
-static unsigned int calc_hash(const struct stat64 *sb)
+static unsigned int calc_hash(const struct stat *sb)
 {
     return (sb->st_size) % MAXHASH;
 }
@@ -1256,7 +1252,7 @@ static int __get_crc(struct inode_entry 
     }
 
     while ((n = read(f1, b1, BUFSIZE)) > 0)
-	crc = crc32(crc, b1, n);
+	crc = crc32(crc, (void *)b1, n);
     close(f1);
     if (n < 0) {
 	fprintf(stderr, "read %s: %s\n", entry->names->name, strerror(errno));