aboutsummaryrefslogtreecommitdiffstats
path: root/com32/libutil
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-03-15 16:57:43 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-03-15 16:57:43 -0700
commitc5e9d7a496936b9ea553be6fef4dff74596bbf11 (patch)
tree2157f08931983c62850f657472b0b86d4ed39e7e /com32/libutil
parent77481cdf403e4170785fada5a44a0efcd2a357e4 (diff)
downloadsyslinux-c5e9d7a496936b9ea553be6fef4dff74596bbf11.tar.gz
syslinux-c5e9d7a496936b9ea553be6fef4dff74596bbf11.tar.xz
syslinux-c5e9d7a496936b9ea553be6fef4dff74596bbf11.zip
Library functions for manipulating initramfs
Library support for constructing initramfs. This version is *not* complete, as it doesn't take into account alignment requirements properly.
Diffstat (limited to 'com32/libutil')
-rw-r--r--com32/libutil/Makefile3
-rw-r--r--com32/libutil/include/syslinux/loadfile.h12
-rw-r--r--com32/libutil/syslinux/loadfile.c69
3 files changed, 1 insertions, 83 deletions
diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile
index eaae4156..7e5335fe 100644
--- a/com32/libutil/Makefile
+++ b/com32/libutil/Makefile
@@ -46,8 +46,7 @@ LNXCFLAGS = -I./include -W -Wall -O -g
LNXSFLAGS = -g
LNXLDFLAGS = -g
OBJCOPY = objcopy
-LIBOBJS = ansiline.o ansiraw.o get_key.o idle.o sha1hash.o unbase64.o \
- syslinux/loadfile.o
+LIBOBJS = ansiline.o ansiraw.o get_key.o idle.o sha1hash.o unbase64.o
LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS))
.SUFFIXES: .lss .c .lo .o .elf .c32 .lnx
diff --git a/com32/libutil/include/syslinux/loadfile.h b/com32/libutil/include/syslinux/loadfile.h
deleted file mode 100644
index fbda589d..00000000
--- a/com32/libutil/include/syslinux/loadfile.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef LIBUTIL_LOADFILE_H
-#define LIBUTIL_LOADFILE_H
-
-#include <stddef.h>
-
-/* loadfile() returns the true size of the file, but will guarantee valid,
- zero-padded memory out to this boundary. */
-#define LOADFILE_ZERO_PAD 64
-
-int loadfile(const char *, void **, size_t *);
-
-#endif
diff --git a/com32/libutil/syslinux/loadfile.c b/com32/libutil/syslinux/loadfile.c
deleted file mode 100644
index 9a4e3ca5..00000000
--- a/com32/libutil/syslinux/loadfile.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2005 H. Peter Anvin - 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, Inc., 53 Temple Place Ste 330,
- * Boston MA 02111-1307, USA; either version 2 of the License, or
- * (at your option) any later version; incorporated herein by reference.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * loadfile.c
- *
- * Read the contents of a data file into a malloc'd buffer
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#include <syslinux/loadfile.h>
-
-int loadfile(const char *filename, void **ptr, size_t *len)
-{
- int fd;
- struct stat st;
- void *data;
- FILE *f;
- size_t xlen;
-
- fd = open(filename, O_RDONLY);
- if ( fd < 0 )
- return -1;
-
- f = fdopen(fd, "rb");
- if ( !f ) {
- close(fd);
- return -1;
- }
-
- if ( fstat(fd, &st) )
- goto err_fclose;
-
- *len = st.st_size;
- xlen = (st.st_size + LOADFILE_ZERO_PAD-1) & ~(LOADFILE_ZERO_PAD-1);
-
- *ptr = data = malloc(xlen);
- if ( !data )
- goto err_fclose;
-
- if ( (off_t)fread(data, 1, st.st_size, f) != st.st_size )
- goto err_free;
-
- memset((char *)data + st.st_size, 0, xlen-st.st_size);
-
- fclose(f);
- return 0;
-
- err_free:
- free(data);
- err_fclose:
- fclose(f);
- return -1;
-}