diff options
author | wiktor w brodlo <wiktor@brodlo.net> | 2011-06-15 16:59:54 +0000 |
---|---|---|
committer | wiktor w brodlo <wiktor@brodlo.net> | 2011-06-15 16:59:54 +0000 |
commit | 2590d96369d0217e31dc2812690dde61dac417b5 (patch) | |
tree | 82276f787b08a28548e342c7921486f1acefab9f /utils/geninitrdsz.c | |
parent | first commit (diff) | |
download | anaconda-2590d96369d0217e31dc2812690dde61dac417b5.tar.gz anaconda-2590d96369d0217e31dc2812690dde61dac417b5.tar.bz2 anaconda-2590d96369d0217e31dc2812690dde61dac417b5.zip |
Initial import from Sabayon (ver 0.9.9.56)
Diffstat (limited to 'utils/geninitrdsz.c')
-rw-r--r-- | utils/geninitrdsz.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/utils/geninitrdsz.c b/utils/geninitrdsz.c new file mode 100644 index 0000000..6dfd976 --- /dev/null +++ b/utils/geninitrdsz.c @@ -0,0 +1,62 @@ +/* + * geninitrdsz.c + * Generate initrd.size file for zSeries platforms. + * Takes an integer argument and writes out the binary representation of + * that value to the initrd.size file. + * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197773 + * + * Copyright (C) 2007 Red Hat, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <netinet/in.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +int main(int argc,char **argv) { + unsigned int zero = 0; + int fd; + unsigned int size; + mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH; + + if (argc != 3) { + printf("Usage: %s [integer size] [output file]\n", basename(argv[0])); + printf("Example: %s 12288475 initrd.size\n", basename(argv[0])); + return 0; + } + + size = htonl(atoi(argv[1])); + fd = open(argv[2], O_CREAT | O_RDWR, mode); + + if (write(fd, &zero, sizeof(int)) == -1) { + perror("writing initrd.size (zero)"); + return errno; + } + + if (write(fd, &size, sizeof(int)) == -1) { + perror("writing initrd.size (size)"); + return errno; + } + + close(fd); + return 0; +} |