aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorroot <root>2007-09-08 16:49:37 +0000
committerroot <root>2007-09-08 16:49:37 +0000
commit44341d32524c1621357bac52ffca7d8e9270c3e4 (patch)
treef9920382c2c19f05d3d09f4f5ce07f2cb1312247 /src
parent77f753281564930411f0a0a0965810fb80f22915 (diff)
downloadgpt-44341d32524c1621357bac52ffca7d8e9270c3e4.tar.gz
gpt-44341d32524c1621357bac52ffca7d8e9270c3e4.tar.bz2
gpt-44341d32524c1621357bac52ffca7d8e9270c3e4.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am60
-rw-r--r--src/gpt.c27
-rw-r--r--src/gpt.h102
-rw-r--r--src/project.h65
-rw-r--r--src/prototypes.h0
-rw-r--r--src/version.c25
6 files changed, 243 insertions, 36 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..6b4b5e4
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,60 @@
+#
+#
+# Makefile.am:
+#
+# Copyright (c) 2007 James McKenzie <james@fishsoup.dhs.org>,
+# All rights reserved.
+#
+# $Id: Makefile.am,v 1.1 2007/09/08 16:49:37 root Exp $
+#
+# $Log: Makefile.am,v $
+# Revision 1.1 2007/09/08 16:49:37 root
+# *** empty log message ***
+#
+#
+#
+#
+
+CPROTO=cproto
+INCLUDES =
+
+noinst_HEADERS=project.h prototypes.h
+
+bin_PROGRAMS = gpt
+
+SRCS=gpt.c version.c
+gpt_SOURCES = ${SRCS}
+gpt_LDADD =
+
+AM_CFLAGS=-g
+
+gpt_LDFLAGS =
+
+BUILT_SOURCES = version.h
+
+
+VFD=${srcdir}/..
+VF=${shell cat ${VFD}/version-files}
+VFS=${VF:%=${VFD}/%}
+VCHK=${shell cat ${VFS} | @MD5SUM@ | @AWK@ '{print $$1 }' }
+VNUM=${shell @GREP@ ${VCHK} ${VFD}/version-md5sums | @AWK@ '{ print $$2 }' }
+VDEF=${shell echo `cat ${VFD}/version-major`.`cat ${VFD}/version-minor`.`cat ${VFD}/version-micro` }
+
+protos:
+ echo > prototypes.h
+ ${CPROTO} -v ${INCLUDES} ${SRCS} > prototypes.tmp
+ mv -f prototypes.tmp prototypes.h
+
+
+
+version.h: $(VFD)/version-files $(VFD)/version-major \
+ $(VFD)/version-minor $(VFD)/version-micro \
+ $(VFD)/version-md5sums ${VFS} Makefile
+ if [ .${VNUM} = . ]; then \
+ echo "#define VERSION \"gpt Version ${VDEF} + Edits\"" > version.h; \
+ echo ${VDEF}-E > version-num; \
+ else \
+ echo "#define VERSION \"gpt Version ${VNUM}\"" > version.h; \
+ echo ${VNUM} > version-num; \
+ fi
+
diff --git a/src/gpt.c b/src/gpt.c
new file mode 100644
index 0000000..f392710
--- /dev/null
+++ b/src/gpt.c
@@ -0,0 +1,27 @@
+/*
+ * gpt.c:
+ *
+ * Copyright (c) 2007 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id: gpt.c,v 1.1 2007/09/08 16:49:37 root Exp $";
+
+/*
+ * $Log: gpt.c,v $
+ * Revision 1.1 2007/09/08 16:49:37 root
+ * *** empty log message ***
+ *
+ */
+
+
+
+#include "project.h"
+
+
+int
+main (int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/src/gpt.h b/src/gpt.h
index 6ae7866..80742ea 100644
--- a/src/gpt.h
+++ b/src/gpt.h
@@ -1,43 +1,73 @@
-
-#define PACKED __attribute__ ( packed )
-
-#define GUID(a)
+#define PACKED __attribute__((packed))
#define TYPE_EMPTY "00000000-0000-0000-0000-000000000000"
#define TYPE_SYSTEM "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
-typedef PACKED struct {
- uint8_t d[16];
-} guid;
-
-typedef PACKED struct {
- guid type;
- guid label;
- uint64_t start;
- uint64_t end;
- uint64_t flags;
-#define FLAG_SYSTEM 1
- uint8_t name[72];
+typedef PACKED struct
+{
+ uint8_t d[16];
+} GUID;
+
+#define GPT_ENTRY_FLAG_SYSTEM 1
+typedef PACKED struct
+{
+ GUID type;
+ GUID label;
+ uint64_t start;
+ uint64_t end;
+ uint64_t flags;
+ uint8_t name[72];
} GPT_entry;
-
-typedef PACKED struct {
-
-
-
-typedef PACKED struct {
-uint8_t boot_code[440];
-uint8_t uid[4];
-uint8_t reserved[2];
-MBR_entry entry[4];
-uint8_t signature[2];
-}
-
-
-
-
-
-
+#define GPT_HEADER_SIGNATURE "EFI PART"
+#define GPT_HEADER_REVISION_EFI10 0x00010000
+
+typedef PACKED struct
+{
+ uint8_t signature[8];
+ uint32_t revision;
+ uint32_t header_size;
+ uint32_t header_crc;
+ uint8_t reserved[20];
+ uint64_t my_lba;
+ uint64_t alternate_lba;
+ uint64_t first_usable_lba;
+ uint64_t last_usable_lba;
+ GUID disk_guid;
+ uint64_t partition_entry_lba;
+ uint32_t n_partition_entries;
+ uint32_t partition_entry_size;
+ uint32_t partition_entry_crc;
+} GPT_header;
+
+
+
+
+#define MBR_PARTITION_TYPE_EFI 0xee
+#define MBR_PARTITION_BOOTABLE 0x80
+
+typedef PACKED struct
+{
+ uint8_t head;
+ uint8_t sector;
+ uint8_t track;
+} CHS;
+
+typedef PACKED struct
+{
+ uint8_t bootable;
+ CHS chs_start;
+ uint8_t system;
+ CHS chs_end;
+ uint32_t start;
+ uint32_t size;
+} MBR_entry;
+
+typedef PACKED struct
+{
+ uint8_t boot_code[440];
+ uint8_t uid[4];
+ uint8_t reserved[2];
+ MBR_entry entry[4];
+ uint8_t signature[2];
} MBR;
-
-
diff --git a/src/project.h b/src/project.h
new file mode 100644
index 0000000..4a1063e
--- /dev/null
+++ b/src/project.h
@@ -0,0 +1,65 @@
+/*
+ * project.h:
+ *
+ * Copyright (c) 2007 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+/*
+ * $Id: project.h,v 1.1 2007/09/08 16:49:37 root Exp $
+ */
+
+/*
+ * $Log: project.h,v $
+ * Revision 1.1 2007/09/08 16:49:37 root
+ * *** empty log message ***
+ *
+ */
+
+#ifndef __PROJECT_H__
+#define __PROJECT_H__
+
+
+#include "config.h"
+
+#ifdef TM_IN_SYS_TIME
+#include <sys/time.h>
+#ifdef TIME_WITH_SYS_TIME
+#include <time.h>
+#endif
+#else
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#endif
+#include <time.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if defined(HAVE_STDINT_H)
+#include <stdint.h>
+#elif defined(HAVE_SYS_INT_TYPES_H)
+#include <sys/int_types.h>
+#endif
+
+#include "prototypes.h"
+
+#endif /* __PROJECT_H__ */
diff --git a/src/prototypes.h b/src/prototypes.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/prototypes.h
diff --git a/src/version.c b/src/version.c
new file mode 100644
index 0000000..49ad791
--- /dev/null
+++ b/src/version.c
@@ -0,0 +1,25 @@
+/*
+ * version.c:
+ *
+ * Copyright (c) 2007 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id: version.c,v 1.1 2007/09/08 16:49:37 root Exp $";
+
+/*
+ * $Log: version.c,v $
+ * Revision 1.1 2007/09/08 16:49:37 root
+ * *** empty log message ***
+ *
+ */
+
+
+#include "version.h"
+
+static char *
+GetVersion(void)
+{
+ return VERSION;
+}