]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: add bsd driver
authorKarel Zak <kzak@redhat.com>
Wed, 10 Jul 2013 15:30:08 +0000 (17:30 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:47:07 +0000 (16:47 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/Makemodule.am
fdisks/fdisk-menu.c
fdisks/fdisk.c
fdisks/fdiskbsdlabel.h [deleted file]
libfdisk/src/Makemodule.am
libfdisk/src/bsd.c [moved from fdisks/fdiskbsdlabel.c with 89% similarity]
libfdisk/src/libfdisk.h

index fa5dcdfd91c45022feb7fd5888b1ca6b915d5a63..1fc56c3c6f31aa803d86a6b9e9140365ce318ca1 100644 (file)
@@ -8,8 +8,6 @@ fdisk_SOURCES = \
        fdisks/fdisk.c \
        fdisks/fdisk.h \
        fdisks/fdisk-ask.c \
-       fdisks/fdiskbsdlabel.c \
-       fdisks/fdiskbsdlabel.h \
        fdisks/fdisk-menu.c \
        fdisks/partname.c \
        fdisks/common.h
index 59289ec9697e85db826f7c74bd90a15b579fdc30..05fc73034173800341562d02c1a0cc62cd6b3e54 100644 (file)
@@ -10,8 +10,6 @@
 #include "pt-sun.h"
 #include "pt-mbr.h"
 
-#include "fdiskbsdlabel.h"
-
 struct menu_entry {
        const char      key;                    /* command key */
        const char      *title;                 /* help string */
index a27d64ee2c783d22d0e1a20daf4d98a3d5dd96c6..b8fc37abe197c829e8a3b789c73bdee6bce188f0 100644 (file)
@@ -37,7 +37,6 @@
 #include "closestream.h"
 
 #include "pt-sun.h"            /* to toggle flags */
-#include "fdiskbsdlabel.h"
 
 #ifdef HAVE_LINUX_COMPILER_H
 # include <linux/compiler.h>
diff --git a/fdisks/fdiskbsdlabel.h b/fdisks/fdiskbsdlabel.h
deleted file mode 100644 (file)
index 5ea0658..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef FDISK_BSD_LABEL_H
-#define FDISK_BSD_LABEL_H
-
-/*
- * Copyright (c) 1987, 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdint.h>
-#include "pt-bsd.h"
-
-/* public bsd specific functions */
-extern int fdisk_bsd_edit_disklabel(struct fdisk_context *cxt);
-extern int fdisk_bsd_write_bootstrap(struct fdisk_context *cxt);
-extern int fdisk_bsd_link_partition(struct fdisk_context *cxt);
-
-
-#endif /* FDISK_BSD_LABEL_H */
index 2dd90eeb36c6dc56fd1f813b8d1738ebd2754882..be5d964d073d8778da7ca75bbf9fc3584acab69c 100644 (file)
@@ -21,6 +21,7 @@ libfdisk_la_SOURCES = \
        libfdisk/src/sun.c \
        libfdisk/src/sgi.c \
        libfdisk/src/dos.c \
+       libfdisk/src/bsd.c \
        libfdisk/src/gpt.c
 
 
similarity index 89%
rename from fdisks/fdiskbsdlabel.c
rename to libfdisk/src/bsd.c
index 87688b235c00c35d5201062c5c2364cd0a5b0cb5..e242c10b4293e6e71e28e8d95fc754a7fad08d76 100644 (file)
@@ -1,47 +1,13 @@
 /*
-   NetBSD disklabel editor for Linux fdisk
-   Written by Bernhard Fastenrath (fasten@informatik.uni-bonn.de)
-   with code from the NetBSD disklabel command:
-
-   Copyright (c) 1987, 1988 Regents of the University of California.
-   All rights reserved.
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-   1. Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-   2. Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-   3. All advertising materials mentioning features or use of this software
-      must display the following acknowledgement:
-       This product includes software developed by the University of
-       California, Berkeley and its contributors.
-   4. Neither the name of the University nor the names of its contributors
-      may be used to endorse or promote products derived from this software
-      without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-   ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-   SUCH DAMAGE.
-
-   Changes:
-   19990319 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> - i18n/nls
-
-   20000101 - David Huggins-Daines <dhuggins@linuxcare.com> - Better
-   support for BSD/1 disklabels on Alpha.
-   Also fixed unaligned accesses in alpha_bootblock_checksum()
-*/
-
+ * Copyright (C) 2007-2013 Karel Zak <kzak@redhat.com>
+ *
+ * Based on the original code from fdisk
+ *    written by Bernhard Fastenrath (fasten@informatik.uni-bonn.de)
+ *    with code from the NetBSD disklabel command.
+ *
+ *    Arnaldo Carvalho de Melo <acme@conectiva.com.br>, March 1999
+ *    David Huggins-Daines <dhuggins@linuxcare.com>, January 2000
+ */
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <sys/param.h>
 
-#include "common.h"
-#include "fdisk.h"
+#include "nls.h"
+#include "blkdev.h"
+#include "fdiskP.h"
 #include "pt-mbr.h"
-
-#include "fdiskbsdlabel.h"
+#include "pt-bsd.h"
 #include "all-io.h"
 
 static const char *bsd_dktypenames[] = {
@@ -120,7 +86,6 @@ struct fdisk_bsd_label {
 static int bsd_list_disklabel(struct fdisk_context *cxt);
 static int bsd_initlabel(struct fdisk_context *cxt);
 static int bsd_readlabel(struct fdisk_context *cxt);
-static int bsd_writelabel(struct fdisk_context *cxt);
 static void sync_disks(struct fdisk_context *cxt);
 
 #define bsd_cround(c, n) \
@@ -222,14 +187,6 @@ static int bsd_probe_label(struct fdisk_context *cxt)
        return 0;               /* not found */
 }
 
-static int bsd_write_disklabel (struct fdisk_context *cxt)
-{
-       fdisk_info(cxt, _("Writing disklabel to %s."), cxt->dev_path);
-       bsd_writelabel(cxt);
-       reread_partition_table(cxt, 0); /* no exit yet */
-       return 0;
-}
-
 static int bsd_add_part (struct fdisk_context *cxt,
                size_t i,
                struct fdisk_parttype *t __attribute__((__unused__)))
@@ -779,14 +736,13 @@ static int bsd_readlabel(struct fdisk_context *cxt)
        return 0;
 }
 
-static int bsd_writelabel(struct fdisk_context *cxt)
+static int bsd_write_disklabel(struct fdisk_context *cxt)
 {
        off_t offset = 0;
-       struct fdisk_bsd_label *l;
-       struct bsd_disklabel *d;
+       struct fdisk_bsd_label *l = self_label(cxt);
+       struct bsd_disklabel *d = self_disklabel(cxt);
 
-       l = self_label(cxt);
-       d = self_disklabel(cxt);
+       fdisk_info(cxt, _("Writing disklabel to %s."), cxt->dev_path);
 
        if (l->dos_part)
                offset = dos_partition_get_start(l->dos_part) * cxt->sector_size;
index f14cdd14216e4f0b4af7b3805f876c7421b6ba8c..1276e99e5ab68596373cadf0ee932afe54306af5 100644 (file)
@@ -165,6 +165,11 @@ extern int fdisk_sun_set_ilfact(struct fdisk_context *cxt);
 extern int fdisk_sun_set_rspeed(struct fdisk_context *cxt);
 extern int fdisk_sun_set_pcylcount(struct fdisk_context *cxt);
 
+/* bsd.c */
+extern int fdisk_bsd_edit_disklabel(struct fdisk_context *cxt);
+extern int fdisk_bsd_write_bootstrap(struct fdisk_context *cxt);
+extern int fdisk_bsd_link_partition(struct fdisk_context *cxt);
+
 /* sgi.h */
 #define SGI_FLAG_BOOT  1
 #define SGI_FLAG_SWAP  2