diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-05-29 15:10:26 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-05-29 15:10:26 -0700 |
commit | 0e1a0d6d9c9e9db569c466390e6c730d6bc0592f (patch) | |
tree | c86155947cb2dfad093405b0195e652fe3cac5fc /com32/lib/syslinux | |
parent | 593fdb26503c193071fcba19b0827212d25c958d (diff) | |
download | syslinux-0e1a0d6d9c9e9db569c466390e6c730d6bc0592f.tar.gz |
Run Nindent on com32/lib/syslinux/initramfs_file.c
Automatically reformat com32/lib/syslinux/initramfs_file.c using Nindent.
Do this for all files except HDT, gPXE and externally maintained
libraries (zlib, tinyjpeg, libpng).
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/lib/syslinux')
-rw-r--r-- | com32/lib/syslinux/initramfs_file.c | 164 |
1 files changed, 81 insertions, 83 deletions
diff --git a/com32/lib/syslinux/initramfs_file.c b/com32/lib/syslinux/initramfs_file.c index 8f8eda64..763eff28 100644 --- a/com32/lib/syslinux/initramfs_file.c +++ b/com32/lib/syslinux/initramfs_file.c @@ -39,20 +39,20 @@ #define CPIO_MAGIC "070701" struct cpio_header { - char c_magic[6]; /* 070701 */ - char c_ino[8]; /* Inode number */ - char c_mode[8]; /* File mode and permissions */ - char c_uid[8]; /* uid */ - char c_gid[8]; /* gid */ - char c_nlink[8]; /* Number of links */ - char c_mtime[8]; /* Modification time */ - char c_filesize[8]; /* Size of data field */ - char c_maj[8]; /* File device major number */ - char c_min[8]; /* File device minor number */ - char c_rmaj[8]; /* Device node reference major number */ - char c_rmin[8]; /* Device node reference minor number */ - char c_namesize[8]; /* Length of filename including final \0 */ - char c_chksum[8]; /* Checksum if c_magic ends in 2 */ + char c_magic[6]; /* 070701 */ + char c_ino[8]; /* Inode number */ + char c_mode[8]; /* File mode and permissions */ + char c_uid[8]; /* uid */ + char c_gid[8]; /* gid */ + char c_nlink[8]; /* Number of links */ + char c_mtime[8]; /* Modification time */ + char c_filesize[8]; /* Size of data field */ + char c_maj[8]; /* File device major number */ + char c_min[8]; /* File device minor number */ + char c_rmaj[8]; /* Device node reference major number */ + char c_rmin[8]; /* Device node reference minor number */ + char c_namesize[8]; /* Length of filename including final \0 */ + char c_chksum[8]; /* Checksum if c_magic ends in 2 */ }; static uint32_t next_ino = 1; @@ -62,38 +62,38 @@ static uint32_t next_ino = 1; static size_t initramfs_mkdirs(const char *filename, void *buffer, size_t buflen) { - const char *p = filename; - char *bp = buffer; - int len; - size_t bytes = 0; - int pad; - - while ((p = strchr(p, '/'))) { - if (p != filename && p[-1] != '/') { - len = p-filename; - bytes += ((sizeof(struct cpio_header)+len+1)+3) & ~3; - } - p++; - } + const char *p = filename; + char *bp = buffer; + int len; + size_t bytes = 0; + int pad; - if (buflen >= bytes) { - p = filename; while ((p = strchr(p, '/'))) { - if (p != filename && p[-1] != '/') { - len = p-filename; - bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x" - "%08x%08x%08x%08x", next_ino++, S_IFDIR|0755, - 0, 0, 1, 0, 0, 0, 1, 0, 1, len+1, 0); - memcpy(bp, filename, len); - bp += len; - pad = (-(sizeof(struct cpio_header)+len) & 3) + 1; - memset(bp, 0, pad); - bp += pad; - } + if (p != filename && p[-1] != '/') { + len = p - filename; + bytes += ((sizeof(struct cpio_header) + len + 1) + 3) & ~3; + } + p++; + } + + if (buflen >= bytes) { + p = filename; + while ((p = strchr(p, '/'))) { + if (p != filename && p[-1] != '/') { + len = p - filename; + bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x" + "%08x%08x%08x%08x", next_ino++, S_IFDIR | 0755, + 0, 0, 1, 0, 0, 0, 1, 0, 1, len + 1, 0); + memcpy(bp, filename, len); + bp += len; + pad = (-(sizeof(struct cpio_header) + len) & 3) + 1; + memset(bp, 0, pad); + bp += pad; + } + } } - } - return bytes; + return bytes; } /* @@ -102,42 +102,41 @@ static size_t initramfs_mkdirs(const char *filename, void *buffer, */ int initramfs_mknod(struct initramfs *ihead, const char *filename, int do_mkdir, - uint16_t mode, size_t len, - uint32_t major, uint32_t minor) + uint16_t mode, size_t len, uint32_t major, uint32_t minor) { - size_t bytes; - int namelen = strlen(filename); - int pad; - char *buffer, *bp; - - if (do_mkdir) - bytes = initramfs_mkdirs(filename, NULL, 0); - else - bytes = 0; - - bytes += ((sizeof(struct cpio_header)+namelen+1)+3) & ~3; - - bp = buffer = malloc(bytes); - if (!buffer) - return -1; - - if (do_mkdir) - bp += initramfs_mkdirs(filename, bp, bytes); - - bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x" - "%08x%08x%08x%08x", next_ino++, mode, - 0, 0, 1, 0, len, 0, 1, major, minor, namelen+1, 0); - memcpy(bp, filename, namelen); - bp += len; - pad = (-(sizeof(struct cpio_header)+namelen) & 3) + 1; - memset(bp, 0, pad); - - if (initramfs_add_data(ihead, buffer, bytes, bytes, 4)) { - free(buffer); - return -1; - } - - return 0; + size_t bytes; + int namelen = strlen(filename); + int pad; + char *buffer, *bp; + + if (do_mkdir) + bytes = initramfs_mkdirs(filename, NULL, 0); + else + bytes = 0; + + bytes += ((sizeof(struct cpio_header) + namelen + 1) + 3) & ~3; + + bp = buffer = malloc(bytes); + if (!buffer) + return -1; + + if (do_mkdir) + bp += initramfs_mkdirs(filename, bp, bytes); + + bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x" + "%08x%08x%08x%08x", next_ino++, mode, + 0, 0, 1, 0, len, 0, 1, major, minor, namelen + 1, 0); + memcpy(bp, filename, namelen); + bp += len; + pad = (-(sizeof(struct cpio_header) + namelen) & 3) + 1; + memset(bp, 0, pad); + + if (initramfs_add_data(ihead, buffer, bytes, bytes, 4)) { + free(buffer); + return -1; + } + + return 0; } /* @@ -149,15 +148,14 @@ int initramfs_add_file(struct initramfs *ihead, const void *data, size_t data_len, size_t len, const char *filename, int do_mkdir, uint32_t mode) { - if (initramfs_mknod(ihead, filename, do_mkdir, - (mode & S_IFMT) ? mode : mode|S_IFREG, - len, 0, 1)) - return -1; + if (initramfs_mknod(ihead, filename, do_mkdir, + (mode & S_IFMT) ? mode : mode | S_IFREG, len, 0, 1)) + return -1; - return initramfs_add_data(ihead, data, data_len, len, 4); + return initramfs_add_data(ihead, data, data_len, len, 4); } int initramfs_add_trailer(struct initramfs *ihead) { - return initramfs_mknod(ihead, "TRAILER!!!", 0, 0, 0, 0, 0); + return initramfs_mknod(ihead, "TRAILER!!!", 0, 0, 0, 0, 0); } |