1 |
vapier 08/12/30 13:34:46 |
2 |
|
3 |
Modified: paxinc.c paxinc.h scanelf.c scanmacho.c |
4 |
Log: |
5 |
convert getstr_perms() to strfileperms() and share it among all files |
6 |
|
7 |
Revision Changes Path |
8 |
1.12 pax-utils/paxinc.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.c?rev=1.12&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.c?rev=1.12&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.c?r1=1.11&r2=1.12 |
13 |
|
14 |
Index: paxinc.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v |
17 |
retrieving revision 1.11 |
18 |
retrieving revision 1.12 |
19 |
diff -u -r1.11 -r1.12 |
20 |
--- paxinc.c 30 Dec 2008 12:15:32 -0000 1.11 |
21 |
+++ paxinc.c 30 Dec 2008 13:34:46 -0000 1.12 |
22 |
@@ -1,7 +1,7 @@ |
23 |
/* |
24 |
* Copyright 2003-2007 Gentoo Foundation |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.11 2008/12/30 12:15:32 vapier Exp $ |
27 |
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.12 2008/12/30 13:34:46 vapier Exp $ |
28 |
* |
29 |
* Copyright 2005-2007 Ned Ludd - <solar@g.o> |
30 |
* Copyright 2005-2007 Mike Frysinger - <vapier@g.o> |
31 |
@@ -128,3 +128,17 @@ |
32 |
|
33 |
return &ret; |
34 |
} |
35 |
+ |
36 |
+/* Convert file perms into octal string */ |
37 |
+const char *strfileperms(const char *fname) |
38 |
+{ |
39 |
+ struct stat st; |
40 |
+ static char buf[8]; |
41 |
+ |
42 |
+ if (stat(fname, &st) == -1) |
43 |
+ return ""; |
44 |
+ |
45 |
+ snprintf(buf, sizeof(buf), "%o", st.st_mode); |
46 |
+ |
47 |
+ return buf + 2; |
48 |
+} |
49 |
|
50 |
|
51 |
|
52 |
1.14 pax-utils/paxinc.h |
53 |
|
54 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.h?rev=1.14&view=markup |
55 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.h?rev=1.14&content-type=text/plain |
56 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.h?r1=1.13&r2=1.14 |
57 |
|
58 |
Index: paxinc.h |
59 |
=================================================================== |
60 |
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxinc.h,v |
61 |
retrieving revision 1.13 |
62 |
retrieving revision 1.14 |
63 |
diff -u -r1.13 -r1.14 |
64 |
--- paxinc.h 30 Dec 2008 12:30:52 -0000 1.13 |
65 |
+++ paxinc.h 30 Dec 2008 13:34:46 -0000 1.14 |
66 |
@@ -1,7 +1,7 @@ |
67 |
/* |
68 |
* Copyright 2005-2007 Gentoo Foundation |
69 |
* Distributed under the terms of the GNU General Public License v2 |
70 |
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.h,v 1.13 2008/12/30 12:30:52 vapier Exp $ |
71 |
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.h,v 1.14 2008/12/30 13:34:46 vapier Exp $ |
72 |
* |
73 |
* Copyright 2005-2007 Ned Ludd - <solar@g.o> |
74 |
* Copyright 2005-2007 Mike Frysinger - <vapier@g.o> |
75 |
@@ -65,6 +65,8 @@ |
76 |
archive_handle *ar_open(const char *filename); |
77 |
archive_member *ar_next(archive_handle *); |
78 |
|
79 |
+const char *strfileperms(const char *fname); |
80 |
+ |
81 |
/* Get a value 'X', compensating for endianness. */ |
82 |
#define EGET(X) \ |
83 |
(__extension__ ({ \ |
84 |
|
85 |
|
86 |
|
87 |
1.206 pax-utils/scanelf.c |
88 |
|
89 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.206&view=markup |
90 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.206&content-type=text/plain |
91 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.205&r2=1.206 |
92 |
|
93 |
Index: scanelf.c |
94 |
=================================================================== |
95 |
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v |
96 |
retrieving revision 1.205 |
97 |
retrieving revision 1.206 |
98 |
diff -u -r1.205 -r1.206 |
99 |
--- scanelf.c 30 Dec 2008 13:13:15 -0000 1.205 |
100 |
+++ scanelf.c 30 Dec 2008 13:34:46 -0000 1.206 |
101 |
@@ -1,13 +1,13 @@ |
102 |
/* |
103 |
* Copyright 2003-2007 Gentoo Foundation |
104 |
* Distributed under the terms of the GNU General Public License v2 |
105 |
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.205 2008/12/30 13:13:15 vapier Exp $ |
106 |
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.206 2008/12/30 13:34:46 vapier Exp $ |
107 |
* |
108 |
* Copyright 2003-2007 Ned Ludd - <solar@g.o> |
109 |
* Copyright 2004-2007 Mike Frysinger - <vapier@g.o> |
110 |
*/ |
111 |
|
112 |
-static const char *rcsid = "$Id: scanelf.c,v 1.205 2008/12/30 13:13:15 vapier Exp $"; |
113 |
+static const char *rcsid = "$Id: scanelf.c,v 1.206 2008/12/30 13:34:46 vapier Exp $"; |
114 |
const char * const argv0 = "scanelf"; |
115 |
|
116 |
#include "paxinc.h" |
117 |
@@ -78,19 +78,6 @@ |
118 |
|
119 |
static int has_objdump = 0; |
120 |
|
121 |
-static const char *getstr_perms(const char *fname) |
122 |
-{ |
123 |
- struct stat st; |
124 |
- static char buf[8]; |
125 |
- |
126 |
- if (stat(fname, &st) == -1) |
127 |
- return ""; |
128 |
- |
129 |
- snprintf(buf, sizeof(buf), "%o", st.st_mode); |
130 |
- |
131 |
- return buf + 2; |
132 |
-} |
133 |
- |
134 |
/* find the path to a file by name */ |
135 |
static char *which(const char *fname) |
136 |
{ |
137 |
@@ -1236,7 +1223,7 @@ |
138 |
case 'r': scanelf_file_rpath(elf, &found_rpath, &out_buffer, &out_len); break; |
139 |
case 'M': out = get_elfeitype(EI_CLASS, elf->data[EI_CLASS]); break; |
140 |
case 'D': out = get_endian(elf); break; |
141 |
- case 'O': out = getstr_perms(elf->filename); break; |
142 |
+ case 'O': out = strfileperms(elf->filename); break; |
143 |
case 'n': |
144 |
case 'N': out = scanelf_file_needed_lib(elf, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break; |
145 |
case 'i': out = scanelf_file_interp(elf, &found_interp); break; |
146 |
|
147 |
|
148 |
|
149 |
1.13 pax-utils/scanmacho.c |
150 |
|
151 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanmacho.c?rev=1.13&view=markup |
152 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanmacho.c?rev=1.13&content-type=text/plain |
153 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanmacho.c?r1=1.12&r2=1.13 |
154 |
|
155 |
Index: scanmacho.c |
156 |
=================================================================== |
157 |
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v |
158 |
retrieving revision 1.12 |
159 |
retrieving revision 1.13 |
160 |
diff -u -r1.12 -r1.13 |
161 |
--- scanmacho.c 30 Dec 2008 13:27:09 -0000 1.12 |
162 |
+++ scanmacho.c 30 Dec 2008 13:34:46 -0000 1.13 |
163 |
@@ -1,7 +1,7 @@ |
164 |
/* |
165 |
* Copyright 2008 Gentoo Foundation |
166 |
* Distributed under the terms of the GNU General Public License v2 |
167 |
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.12 2008/12/30 13:27:09 vapier Exp $ |
168 |
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.13 2008/12/30 13:34:46 vapier Exp $ |
169 |
* |
170 |
* based on scanelf by: |
171 |
* Copyright 2003-2007 Ned Ludd - <solar@g.o> |
172 |
@@ -10,7 +10,7 @@ |
173 |
* 2008 Fabian Groffen - <grobian@g.o> |
174 |
*/ |
175 |
|
176 |
-static const char *rcsid = "$Id: scanmacho.c,v 1.12 2008/12/30 13:27:09 vapier Exp $"; |
177 |
+static const char *rcsid = "$Id: scanmacho.c,v 1.13 2008/12/30 13:34:46 vapier Exp $"; |
178 |
const char * const argv0 = "scanmacho"; |
179 |
|
180 |
#include "paxinc.h" |
181 |
@@ -53,19 +53,6 @@ |
182 |
static int match_bits = 0; |
183 |
static unsigned int match_perms = 0; |
184 |
|
185 |
-static const char *getstr_perms(const char *fname) |
186 |
-{ |
187 |
- struct stat st; |
188 |
- static char buf[8]; |
189 |
- |
190 |
- if (stat(fname, &st) == -1) |
191 |
- return ""; |
192 |
- |
193 |
- snprintf(buf, sizeof(buf), "%o", st.st_mode); |
194 |
- |
195 |
- return buf + 2; |
196 |
-} |
197 |
- |
198 |
static const char *macho_file_needed_lib( |
199 |
fatobj *fobj, |
200 |
char *found_needed, |
201 |
@@ -267,7 +254,7 @@ |
202 |
case 'o': out = get_machomhtype(fobj); break; |
203 |
case 'M': out = get_machocputype(fobj); break; |
204 |
case 'D': out = get_machoendian(fobj); break; |
205 |
- case 'O': out = getstr_perms(fobj->filename); break; |
206 |
+ case 'O': out = strfileperms(fobj->filename); break; |
207 |
case 'n': |
208 |
case 'N': out = macho_file_needed_lib(fobj, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break; |
209 |
case 'i': out = macho_file_interp(fobj, &found_interp); break; |