From: Karel Zak Date: Wed, 10 Jul 2013 15:30:08 +0000 (+0200) Subject: libfdisk: add bsd driver X-Git-Tag: v2.24-rc1~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5b2b8dbbb46c09741c1b8d73b6c9c4629fc1244;p=thirdparty%2Futil-linux.git libfdisk: add bsd driver Signed-off-by: Karel Zak --- diff --git a/fdisks/Makemodule.am b/fdisks/Makemodule.am index fa5dcdfd91..1fc56c3c6f 100644 --- a/fdisks/Makemodule.am +++ b/fdisks/Makemodule.am @@ -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 diff --git a/fdisks/fdisk-menu.c b/fdisks/fdisk-menu.c index 59289ec969..05fc730341 100644 --- a/fdisks/fdisk-menu.c +++ b/fdisks/fdisk-menu.c @@ -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 */ diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index a27d64ee2c..b8fc37abe1 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -37,7 +37,6 @@ #include "closestream.h" #include "pt-sun.h" /* to toggle flags */ -#include "fdiskbsdlabel.h" #ifdef HAVE_LINUX_COMPILER_H # include diff --git a/fdisks/fdiskbsdlabel.h b/fdisks/fdiskbsdlabel.h deleted file mode 100644 index 5ea0658be3..0000000000 --- a/fdisks/fdiskbsdlabel.h +++ /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 -#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 */ diff --git a/libfdisk/src/Makemodule.am b/libfdisk/src/Makemodule.am index 2dd90eeb36..be5d964d07 100644 --- a/libfdisk/src/Makemodule.am +++ b/libfdisk/src/Makemodule.am @@ -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 diff --git a/fdisks/fdiskbsdlabel.c b/libfdisk/src/bsd.c similarity index 89% rename from fdisks/fdiskbsdlabel.c rename to libfdisk/src/bsd.c index 87688b235c..e242c10b42 100644 --- a/fdisks/fdiskbsdlabel.c +++ b/libfdisk/src/bsd.c @@ -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 - i18n/nls - - 20000101 - David Huggins-Daines - Better - support for BSD/1 disklabels on Alpha. - Also fixed unaligned accesses in alpha_bootblock_checksum() -*/ - + * Copyright (C) 2007-2013 Karel Zak + * + * 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 , March 1999 + * David Huggins-Daines , January 2000 + */ #include #include #include @@ -52,11 +18,11 @@ #include -#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; diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h index f14cdd1421..1276e99e5a 100644 --- a/libfdisk/src/libfdisk.h +++ b/libfdisk/src/libfdisk.h @@ -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