diff options
author | Olaf Hering <olh@suse.de> | 2005-11-09 14:52:20 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-11-09 19:25:32 -0500 |
commit | 58638bffe3d594ed3a902824ea40a4196c745bbd (patch) | |
tree | a15587d1559a421d794667a173775b78c5e7896a /arch/ppc64 | |
parent | eba2fb2dac93ed01a9f85b2f623b49a93bef3ed7 (diff) |
[PATCH] ppc64 boot: remove argv usage
Use a local variable for the input filenames.
Signed-off-by: Olaf Hering <olh@suse.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc64')
-rw-r--r-- | arch/ppc64/boot/addRamDisk.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/arch/ppc64/boot/addRamDisk.c b/arch/ppc64/boot/addRamDisk.c index c4e5de96142b..c10746a187b6 100644 --- a/arch/ppc64/boot/addRamDisk.c +++ b/arch/ppc64/boot/addRamDisk.c | |||
@@ -39,6 +39,7 @@ int main(int argc, char **argv) | |||
39 | FILE *inputVmlinux; | 39 | FILE *inputVmlinux; |
40 | FILE *outputVmlinux; | 40 | FILE *outputVmlinux; |
41 | 41 | ||
42 | char *rd_name, *lx_name, *out_name; | ||
42 | unsigned i; | 43 | unsigned i; |
43 | unsigned long ramFileLen; | 44 | unsigned long ramFileLen; |
44 | unsigned long ramLen; | 45 | unsigned long ramLen; |
@@ -69,6 +70,7 @@ int main(int argc, char **argv) | |||
69 | fprintf(stderr, "Name of RAM disk file missing.\n"); | 70 | fprintf(stderr, "Name of RAM disk file missing.\n"); |
70 | exit(1); | 71 | exit(1); |
71 | } | 72 | } |
73 | rd_name = argv[1] | ||
72 | 74 | ||
73 | if (argc < 3) { | 75 | if (argc < 3) { |
74 | fprintf(stderr, "Name of System Map input file is missing.\n"); | 76 | fprintf(stderr, "Name of System Map input file is missing.\n"); |
@@ -79,16 +81,18 @@ int main(int argc, char **argv) | |||
79 | fprintf(stderr, "Name of vmlinux file missing.\n"); | 81 | fprintf(stderr, "Name of vmlinux file missing.\n"); |
80 | exit(1); | 82 | exit(1); |
81 | } | 83 | } |
84 | lx_name = argv[3]; | ||
82 | 85 | ||
83 | if (argc < 5) { | 86 | if (argc < 5) { |
84 | fprintf(stderr, "Name of vmlinux output file missing.\n"); | 87 | fprintf(stderr, "Name of vmlinux output file missing.\n"); |
85 | exit(1); | 88 | exit(1); |
86 | } | 89 | } |
90 | out_name = argv[4]; | ||
87 | 91 | ||
88 | 92 | ||
89 | ramDisk = fopen(argv[1], "r"); | 93 | ramDisk = fopen(rd_name, "r"); |
90 | if ( ! ramDisk ) { | 94 | if ( ! ramDisk ) { |
91 | fprintf(stderr, "RAM disk file \"%s\" failed to open.\n", argv[1]); | 95 | fprintf(stderr, "RAM disk file \"%s\" failed to open.\n", rd_name); |
92 | exit(1); | 96 | exit(1); |
93 | } | 97 | } |
94 | 98 | ||
@@ -98,15 +102,15 @@ int main(int argc, char **argv) | |||
98 | exit(1); | 102 | exit(1); |
99 | } | 103 | } |
100 | 104 | ||
101 | inputVmlinux = fopen(argv[3], "r"); | 105 | inputVmlinux = fopen(lx_name, "r"); |
102 | if ( ! inputVmlinux ) { | 106 | if ( ! inputVmlinux ) { |
103 | fprintf(stderr, "vmlinux file \"%s\" failed to open.\n", argv[3]); | 107 | fprintf(stderr, "vmlinux file \"%s\" failed to open.\n", lx_name); |
104 | exit(1); | 108 | exit(1); |
105 | } | 109 | } |
106 | 110 | ||
107 | outputVmlinux = fopen(argv[4], "w+"); | 111 | outputVmlinux = fopen(out_name, "w+"); |
108 | if ( ! outputVmlinux ) { | 112 | if ( ! outputVmlinux ) { |
109 | fprintf(stderr, "output vmlinux file \"%s\" failed to open.\n", argv[4]); | 113 | fprintf(stderr, "output vmlinux file \"%s\" failed to open.\n", out_name); |
110 | exit(1); | 114 | exit(1); |
111 | } | 115 | } |
112 | 116 | ||
@@ -194,7 +198,7 @@ int main(int argc, char **argv) | |||
194 | fseek(ramDisk, 0, SEEK_END); | 198 | fseek(ramDisk, 0, SEEK_END); |
195 | ramFileLen = ftell(ramDisk); | 199 | ramFileLen = ftell(ramDisk); |
196 | fseek(ramDisk, 0, SEEK_SET); | 200 | fseek(ramDisk, 0, SEEK_SET); |
197 | printf("%s file size = %ld/0x%lx \n", argv[1], ramFileLen, ramFileLen); | 201 | printf("%s file size = %ld/0x%lx \n", rd_name, ramFileLen, ramFileLen); |
198 | 202 | ||
199 | ramLen = ramFileLen; | 203 | ramLen = ramFileLen; |
200 | 204 | ||
@@ -248,7 +252,7 @@ int main(int argc, char **argv) | |||
248 | /* fseek to the hvReleaseData pointer */ | 252 | /* fseek to the hvReleaseData pointer */ |
249 | fseek(outputVmlinux, ElfHeaderSize + 0x24, SEEK_SET); | 253 | fseek(outputVmlinux, ElfHeaderSize + 0x24, SEEK_SET); |
250 | if (fread(&hvReleaseData, 4, 1, outputVmlinux) != 1) { | 254 | if (fread(&hvReleaseData, 4, 1, outputVmlinux) != 1) { |
251 | death("Could not read hvReleaseData pointer\n", outputVmlinux, argv[4]); | 255 | death("Could not read hvReleaseData pointer\n", outputVmlinux, out_name); |
252 | } | 256 | } |
253 | hvReleaseData = ntohl(hvReleaseData); /* Convert to native int */ | 257 | hvReleaseData = ntohl(hvReleaseData); /* Convert to native int */ |
254 | printf("hvReleaseData is at %08x\n", hvReleaseData); | 258 | printf("hvReleaseData is at %08x\n", hvReleaseData); |
@@ -256,11 +260,11 @@ int main(int argc, char **argv) | |||
256 | /* fseek to the hvReleaseData */ | 260 | /* fseek to the hvReleaseData */ |
257 | fseek(outputVmlinux, ElfHeaderSize + hvReleaseData, SEEK_SET); | 261 | fseek(outputVmlinux, ElfHeaderSize + hvReleaseData, SEEK_SET); |
258 | if (fread(inbuf, 0x40, 1, outputVmlinux) != 1) { | 262 | if (fread(inbuf, 0x40, 1, outputVmlinux) != 1) { |
259 | death("Could not read hvReleaseData\n", outputVmlinux, argv[4]); | 263 | death("Could not read hvReleaseData\n", outputVmlinux, out_name); |
260 | } | 264 | } |
261 | /* Check hvReleaseData sanity */ | 265 | /* Check hvReleaseData sanity */ |
262 | if (memcmp(inbuf, &eyeCatcher, 4) != 0) { | 266 | if (memcmp(inbuf, &eyeCatcher, 4) != 0) { |
263 | death("hvReleaseData is invalid\n", outputVmlinux, argv[4]); | 267 | death("hvReleaseData is invalid\n", outputVmlinux, out_name); |
264 | } | 268 | } |
265 | /* Get the naca pointer */ | 269 | /* Get the naca pointer */ |
266 | naca = ntohl(*((u_int32_t*) &inbuf[0x0C])) - KERNELBASE; | 270 | naca = ntohl(*((u_int32_t*) &inbuf[0x0C])) - KERNELBASE; |
@@ -269,13 +273,13 @@ int main(int argc, char **argv) | |||
269 | /* fseek to the naca */ | 273 | /* fseek to the naca */ |
270 | fseek(outputVmlinux, ElfHeaderSize + naca, SEEK_SET); | 274 | fseek(outputVmlinux, ElfHeaderSize + naca, SEEK_SET); |
271 | if (fread(inbuf, 0x18, 1, outputVmlinux) != 1) { | 275 | if (fread(inbuf, 0x18, 1, outputVmlinux) != 1) { |
272 | death("Could not read naca\n", outputVmlinux, argv[4]); | 276 | death("Could not read naca\n", outputVmlinux, out_name); |
273 | } | 277 | } |
274 | xRamDisk = ntohl(*((u_int32_t *) &inbuf[0x0c])); | 278 | xRamDisk = ntohl(*((u_int32_t *) &inbuf[0x0c])); |
275 | xRamDiskSize = ntohl(*((u_int32_t *) &inbuf[0x14])); | 279 | xRamDiskSize = ntohl(*((u_int32_t *) &inbuf[0x14])); |
276 | /* Make sure a RAM disk isn't already present */ | 280 | /* Make sure a RAM disk isn't already present */ |
277 | if ((xRamDisk != 0) || (xRamDiskSize != 0)) { | 281 | if ((xRamDisk != 0) || (xRamDiskSize != 0)) { |
278 | death("RAM disk is already attached to this kernel\n", outputVmlinux, argv[4]); | 282 | death("RAM disk is already attached to this kernel\n", outputVmlinux, out_name); |
279 | } | 283 | } |
280 | /* Fill in the values */ | 284 | /* Fill in the values */ |
281 | *((u_int32_t *) &inbuf[0x0c]) = htonl(ramStartOffs); | 285 | *((u_int32_t *) &inbuf[0x0c]) = htonl(ramStartOffs); |
@@ -285,7 +289,7 @@ int main(int argc, char **argv) | |||
285 | fflush(outputVmlinux); | 289 | fflush(outputVmlinux); |
286 | fseek(outputVmlinux, ElfHeaderSize + naca, SEEK_SET); | 290 | fseek(outputVmlinux, ElfHeaderSize + naca, SEEK_SET); |
287 | if (fwrite(inbuf, 0x18, 1, outputVmlinux) != 1) { | 291 | if (fwrite(inbuf, 0x18, 1, outputVmlinux) != 1) { |
288 | death("Could not write naca\n", outputVmlinux, argv[4]); | 292 | death("Could not write naca\n", outputVmlinux, out_name); |
289 | } | 293 | } |
290 | printf("Ram Disk of 0x%lx pages is attached to the kernel at offset 0x%08x\n", | 294 | printf("Ram Disk of 0x%lx pages is attached to the kernel at offset 0x%08x\n", |
291 | ramPages, ramStartOffs); | 295 | ramPages, ramStartOffs); |
@@ -293,7 +297,7 @@ int main(int argc, char **argv) | |||
293 | /* Done */ | 297 | /* Done */ |
294 | fclose(outputVmlinux); | 298 | fclose(outputVmlinux); |
295 | /* Set permission to executable */ | 299 | /* Set permission to executable */ |
296 | chmod(argv[4], S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); | 300 | chmod(out_name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); |
297 | 301 | ||
298 | return 0; | 302 | return 0; |
299 | } | 303 | } |