summaryrefslogtreecommitdiffstats
path: root/lib/libdisk
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1996-03-24 18:55:39 +0000
committerjoerg <joerg@FreeBSD.org>1996-03-24 18:55:39 +0000
commit18d2a8c9e5387edcde838e92ed58f3612eae5509 (patch)
tree80feac0531a85adb4f38e22d68a6af44b6835fcb /lib/libdisk
parent4f2da6c6e432a586e31d4261f9c4110e109e428a (diff)
downloadFreeBSD-src-18d2a8c9e5387edcde838e92ed58f3612eae5509.zip
FreeBSD-src-18d2a8c9e5387edcde838e92ed58f3612eae5509.tar.gz
Make libdisk C++ aware:
- add __BEGIN_DECLS and __END_DECLS, - add a bunch of ``const'' qualifiers all over the place, - rename the `private' struct member into `private_data' to avoid the clash with the C++ keyword.
Diffstat (limited to 'lib/libdisk')
-rw-r--r--lib/libdisk/chunk.c17
-rw-r--r--lib/libdisk/create_chunk.c8
-rw-r--r--lib/libdisk/disk.c12
-rw-r--r--lib/libdisk/libdisk.323
-rw-r--r--lib/libdisk/libdisk.h221
-rw-r--r--lib/libdisk/tst01.c3
6 files changed, 147 insertions, 137 deletions
diff --git a/lib/libdisk/chunk.c b/lib/libdisk/chunk.c
index 906911a..a34b348 100644
--- a/lib/libdisk/chunk.c
+++ b/lib/libdisk/chunk.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: chunk.c,v 1.14.2.2 1995/06/05 02:24:25 jkh Exp $
+ * $Id: chunk.c,v 1.15 1995/06/11 19:29:32 rgrimes Exp $
*
*/
@@ -75,8 +75,8 @@ void
Free_Chunk(struct chunk *c1)
{
if(!c1) return;
- if(c1->private && c1->private_free)
- (*c1->private_free)(c1->private);
+ if(c1->private_data && c1->private_free)
+ (*c1->private_free)(c1->private_data);
if(c1->part)
Free_Chunk(c1->part);
if(c1->next)
@@ -94,8 +94,8 @@ Clone_Chunk(struct chunk *c1)
c2 = new_chunk();
if (!c2) err(1,"malloc failed");
*c2 = *c1;
- if (c1->private && c1->private_clone)
- c2->private = c2->private_clone(c2->private);
+ if (c1->private_data && c1->private_clone)
+ c2->private_data = c2->private_clone(c2->private_data);
c2->name = strdup(c2->name);
c2->next = Clone_Chunk(c2->next);
c2->part = Clone_Chunk(c2->part);
@@ -103,7 +103,8 @@ Clone_Chunk(struct chunk *c1)
}
int
-Insert_Chunk(struct chunk *c2, u_long offset, u_long size, char *name, chunk_e type, int subtype, u_long flags)
+Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
+ chunk_e type, int subtype, u_long flags)
{
struct chunk *ct,*cs;
@@ -176,8 +177,8 @@ Insert_Chunk(struct chunk *c2, u_long offset, u_long size, char *name, chunk_e t
}
int
-Add_Chunk(struct disk *d, long offset, u_long size, char *name, chunk_e type,
- int subtype, u_long flags)
+Add_Chunk(struct disk *d, long offset, u_long size, const char *name,
+ chunk_e type, int subtype, u_long flags)
{
struct chunk *c1,*c2,ct;
u_long end = offset + size - 1;
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 6c32a7d..05a22a2 100644
--- a/lib/libdisk/create_chunk.c
+++ b/lib/libdisk/create_chunk.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: create_chunk.c,v 1.21.2.6 1995/11/18 10:02:10 jkh Exp $
+ * $Id: create_chunk.c,v 1.22 1995/12/07 10:33:20 peter Exp $
*
*/
@@ -244,7 +244,7 @@ Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e ty
}
int
-MakeDev(struct chunk *c1, char *path)
+MakeDev(struct chunk *c1, const char *path)
{
char *p = c1->name;
u_long cmaj, bmaj, min, unit, part, slice;
@@ -340,7 +340,7 @@ MakeDev(struct chunk *c1, char *path)
}
int
-MakeDevChunk(struct chunk *c1, char *path)
+MakeDevChunk(struct chunk *c1, const char *path)
{
int i;
@@ -353,7 +353,7 @@ MakeDevChunk(struct chunk *c1, char *path)
}
int
-MakeDevDisk(struct disk *d, char *path)
+MakeDevDisk(struct disk *d, const char *path)
{
return MakeDevChunk(d->chunks, path);
}
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index cfac7b5..911eece 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: disk.c,v 1.19.2.2 1995/06/05 02:24:27 jkh Exp $
+ * $Id: disk.c,v 1.20 1995/06/11 19:29:34 rgrimes Exp $
*
*/
@@ -26,7 +26,7 @@
#define DOSPTYP_EXTENDED 5
#define DOSPTYP_ONTRACK 84
-char *chunk_n[] = {
+const char *chunk_n[] = {
"whole",
"unknown",
"fat",
@@ -38,13 +38,13 @@ char *chunk_n[] = {
};
struct disk *
-Open_Disk(char *name)
+Open_Disk(const char *name)
{
return Int_Open_Disk(name,0);
}
struct disk *
-Int_Open_Disk(char *name, u_long size)
+Int_Open_Disk(const char *name, u_long size)
{
int i,fd;
struct diskslices ds;
@@ -300,7 +300,7 @@ Disk_Names()
}
void
-Set_Boot_Mgr(struct disk *d, u_char *b)
+Set_Boot_Mgr(struct disk *d, const u_char *b)
{
if (d->bootmgr)
free(d->bootmgr);
@@ -314,7 +314,7 @@ Set_Boot_Mgr(struct disk *d, u_char *b)
}
void
-Set_Boot_Blocks(struct disk *d, u_char *b1, u_char *b2)
+Set_Boot_Blocks(struct disk *d, const u_char *b1, const u_char *b2)
{
if (d->boot1) free(d->boot1);
d->boot1 = malloc(512);
diff --git a/lib/libdisk/libdisk.3 b/lib/libdisk/libdisk.3
index cf8b05b..3746dec 100644
--- a/lib/libdisk/libdisk.3
+++ b/lib/libdisk/libdisk.3
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: libdisk.3,v 1.1 1996/03/17 23:20:09 joerg Exp $
.\" "
.Dd March 15, 1996
.Dt LIBDISK 3
@@ -61,8 +61,9 @@
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Fd #include <libdisk.h>
+.Dv extern const u_char *boot1, boot2;
.Ft struct disk *
-.Fn Open_Disk "char *devname"
+.Fn Open_Disk "const char *devname"
.Ft struct disk *
.Fn Clone_Disk "struct disk *disk"
.Ft void
@@ -86,9 +87,9 @@
.Ft char **
.Fn Disk_Names "void"
.Ft void
-.Fn Set_Boot_Mgr "struct disk *d" "u_char *bootmgr"
+.Fn Set_Boot_Mgr "struct disk *d" "const u_char *bootmgr"
.Ft void
-.Fn Set_Boot_Blocks "struct disk *d" "u_char *boot1" "u_char *boot2"
+.Fn Set_Boot_Blocks "struct disk *d" "const u_char *boot1" "const u_char *boot2"
.Ft int
.Fn Write_Disk "struct disk *d"
.Ft int
@@ -106,9 +107,9 @@
.Ft struct chunk *
.Fn Create_Chunk_DWIM "struct disk *d" "struct chunk *parent" "u_long size" "chunk_e type" "int subtype" "u_long flags"
.Ft int
-.Fn MakeDev "struct chunk *c" "char *path"
+.Fn MakeDev "struct chunk *c" "const char *path"
.Ft int
-.Fn MakeDevDisk "struct disk *d,char *path"
+.Fn MakeDevDisk "struct disk *d" "const char *path"
.Ft char *
.Fn ShowChunkFlags "struct chunk *c"
.Ft char *
@@ -155,7 +156,7 @@ struct chunk {
u_long flags;
void (*private_free)(void*);
void *(*private_clone)(void*);
- void *private;
+ void *private_data;
};
.Ed
The
@@ -190,7 +191,7 @@ considerations.
.El
.Pp
The
-.Ql private ,
+.Ql private_data ,
.Ql private_free ,
and
.Ql private_clone
@@ -254,7 +255,11 @@ is called.
.Fn Set_Boot_Blocks
sets the boot-blocks for use on this disk. Gets written when
.Fn Write_Disk
-is called.
+is called. The external variables
+.Dv boot1
+and
+.Dv boot2
+contain suitable data to be passed to this function.
.Pp
.Fn Write_Disk
writes all the MBRs, disklabels, bootblocks and boot managers.
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index e277f87..1473e72 100644
--- a/lib/libdisk/libdisk.h
+++ b/lib/libdisk/libdisk.h
@@ -1,17 +1,17 @@
/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $Id: libdisk.h,v 1.19.2.2 1995/10/13 08:19:12 jkh Exp $
- *
- */
+* ----------------------------------------------------------------------------
+* "THE BEER-WARE LICENSE" (Revision 42):
+* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
+* can do whatever you want with this stuff. If we meet some day, and you think
+* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+* ----------------------------------------------------------------------------
+*
+* $Id: libdisk.h,v 1.20 1995/12/07 10:33:21 peter Exp $
+*
+*/
#define MAX_NO_DISKS 20
- /* Max # of disks Disk_Names() will return */
+/* Max # of disks Disk_Names() will return */
typedef enum {
whole,
@@ -21,10 +21,9 @@ typedef enum {
extended,
part,
unused,
- } chunk_e;
-
-extern char *chunk_n[];
+} chunk_e;
+__BEGIN_DECLS
struct disk {
char *name;
u_long flags;
@@ -52,185 +51,190 @@ struct chunk {
u_long end;
char *name;
char *oname;
- /* Used during Fixup_Names() to avoid renaming more than
- * absolutely needed.
- */
+ /* Used during Fixup_Names() to avoid renaming more than
+ * absolutely needed.
+ */
chunk_e type;
int subtype;
u_long flags;
# define CHUNK_PAST_1024 1
- /* this chunk cannot be booted from because it
- * extends past cylinder 1024
- */
+ /* this chunk cannot be booted from because it
+ * extends past cylinder 1024
+ */
# define CHUNK_BSD_COMPAT 2
- /* this chunk is in the BSD-compatibility, and has a
- * short name too, ie wd0s4f -> wd0f
- */
+ /* this chunk is in the BSD-compatibility, and has a
+ * short name too, ie wd0s4f -> wd0f
+ */
# define CHUNK_BAD144 4
- /* this chunk has bad144 mapping */
+ /* this chunk has bad144 mapping */
# define CHUNK_ALIGN 8
- /* This chunk should be aligned */
+ /* This chunk should be aligned */
# define CHUNK_IS_ROOT 16
- /* This 'part' is a rootfs, allocate 'a' */
+ /* This 'part' is a rootfs, allocate 'a' */
# define CHUNK_ACTIVE 32
- /* This is the active slice in the MBR */
+ /* This is the active slice in the MBR */
# define CHUNK_FORCE_ALL 64
- /* Force a dedicated disk for FreeBSD, bypassing
- * all BIOS geometry considerations
- */
+ /* Force a dedicated disk for FreeBSD, bypassing
+ * all BIOS geometry considerations
+ */
void (*private_free)(void*);
void *(*private_clone)(void*);
- void *private;
- /* For data private to the application, and the management
- * thereof. If the functions are not provided, no storage
- * management is done, Cloning will just copy the pointer
- * and freeing will just forget it.
- */
+ void *private_data;
+ /* For data private to the application, and the management
+ * thereof. If the functions are not provided, no storage
+ * management is done, Cloning will just copy the pointer
+ * and freeing will just forget it.
+ */
};
+extern const char *chunk_n[];
+extern const u_char *boot1, *boot2;
+
struct disk *
-Open_Disk(char *devname);
- /* Will open the named disk, and return populated tree.
- */
+Open_Disk(const char *devname);
+/* Will open the named disk, and return populated tree.
+ */
struct disk *
Clone_Disk(struct disk *disk);
- /* Clone a copy of a tree. Useful for "Undo" functionality
- */
+/* Clone a copy of a tree. Useful for "Undo" functionality
+ */
void
Free_Disk(struct disk *disk);
- /* Free a tree made with Open_Disk() or Clone_Disk()
- */
+/* Free a tree made with Open_Disk() or Clone_Disk()
+ */
void
Debug_Disk(struct disk *disk);
- /* Print the content of the tree to stdout
- */
+/* Print the content of the tree to stdout
+ */
#if 0
struct disk *
Set_Phys_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects);
- /* Use a different physical geometry. Makes sense for ST506 disks only.
- * The tree returned is read from the disk, using this geometry.
- */
+/* Use a different physical geometry. Makes sense for ST506 disks only.
+ * The tree returned is read from the disk, using this geometry.
+ */
#endif
void
Set_Bios_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects);
- /* Set the geometry the bios uses.
- */
+/* Set the geometry the bios uses.
+ */
int
Delete_Chunk(struct disk *disk, struct chunk *);
- /* Free a chunk of disk_space
- */
+/* Free a chunk of disk_space
+ */
void
Collapse_Disk(struct disk *disk);
- /* Experimental, do not use.
- */
+/* Experimental, do not use.
+ */
int
Collapse_Chunk(struct disk *disk, struct chunk *chunk);
- /* Experimental, do not use.
- */
+/* Experimental, do not use.
+ */
int
-Create_Chunk(struct disk *disk, u_long offset, u_long size, chunk_e type, int subtype, u_long flags);
- /* Create a chunk with the specified paramters
- */
+Create_Chunk(struct disk *disk, u_long offset, u_long size, chunk_e type,
+ int subtype, u_long flags);
+/* Create a chunk with the specified paramters
+ */
void
All_FreeBSD(struct disk *d, int force_all);
- /* Make one FreeBSD chunk covering the entire disk;
- * if force_all is set, bypass all BIOS geometry
- * considerations.
- */
+/* Make one FreeBSD chunk covering the entire disk;
+ * if force_all is set, bypass all BIOS geometry
+ * considerations.
+ */
char *
CheckRules(struct disk *);
- /* Return char* to warnings about broken design rules in this disklayout
- */
+/* Return char* to warnings about broken design rules in this disklayout
+ */
char **
Disk_Names();
- /* Return char** with all disk's names (wd0, wd1 ...). You must free
- * each pointer, as well as the array by hand
- */
+/* Return char** with all disk's names (wd0, wd1 ...). You must free
+ * each pointer, as well as the array by hand
+ */
void
-Set_Boot_Mgr(struct disk *d, u_char *bootmgr);
- /* Use this boot-manager on this disk. Gets written when Write_Disk()
- * is called
- */
+Set_Boot_Mgr(struct disk *d, const u_char *bootmgr);
+/* Use this boot-manager on this disk. Gets written when Write_Disk()
+ * is called
+ */
void
-Set_Boot_Blocks(struct disk *d, u_char *boot1, u_char *boot2);
- /* Use these boot-blocks on this disk. Gets written when Write_Disk()
- * is called
- */
+Set_Boot_Blocks(struct disk *d, const u_char *boot1, const u_char *boot2);
+/* Use these boot-blocks on this disk. Gets written when Write_Disk()
+ * is called
+ */
int
Write_Disk(struct disk *d);
- /* Write all the MBRs, disklabels, bootblocks and boot managers
- */
+/* Write all the MBRs, disklabels, bootblocks and boot managers
+ */
int
Cyl_Aligned(struct disk *d, u_long offset);
- /* Check if offset is aligned on a cylinder according to the
- * bios geometry
- */
+/* Check if offset is aligned on a cylinder according to the
+ * bios geometry
+ */
u_long
Next_Cyl_Aligned(struct disk *d, u_long offset);
- /* Round offset up to next cylinder according to the bios-geometry
- */
+/* Round offset up to next cylinder according to the bios-geometry
+ */
u_long
Prev_Cyl_Aligned(struct disk *d, u_long offset);
- /* Round offset down to previous cylinder according to the bios-
- * geometry
- */
+/* Round offset down to previous cylinder according to the bios-
+ * geometry
+ */
int
Track_Aligned(struct disk *d, u_long offset);
- /* Check if offset is aligned on a track according to the
- * bios geometry
- */
+/* Check if offset is aligned on a track according to the
+ * bios geometry
+ */
u_long
Next_Track_Aligned(struct disk *d, u_long offset);
- /* Round offset up to next track according to the bios-geometry
- */
+/* Round offset up to next track according to the bios-geometry
+ */
u_long
Prev_Track_Aligned(struct disk *d, u_long offset);
- /* Check if offset is aligned on a track according to the
- * bios geometry
- */
+/* Check if offset is aligned on a track according to the
+ * bios geometry
+ */
struct chunk *
-Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags);
- /* This one creates a partition inside the given parent of the given
- * size, and returns a pointer to it. The first unused chunk big
- * enough is used.
- */
+Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size,
+ chunk_e type, int subtype, u_long flags);
+/* This one creates a partition inside the given parent of the given
+ * size, and returns a pointer to it. The first unused chunk big
+ * enough is used.
+ */
int
-MakeDev(struct chunk *c, char *path);
+MakeDev(struct chunk *c, const char *path);
int
-MakeDevDisk(struct disk *d,char *path);
- /* Make device nodes for all chunks on this disk */
+MakeDevDisk(struct disk *d, const char *path);
+/* Make device nodes for all chunks on this disk */
char *
ShowChunkFlags(struct chunk *c);
- /* Return string to show flags. */
+/* Return string to show flags. */
char *
ChunkCanBeRoot(struct chunk *c);
- /* Return NULL if chunk can be /, explanation otherwise */
+/* Return NULL if chunk can be /, explanation otherwise */
/*
* Implementation details >>> DO NOT USE <<<
@@ -239,15 +243,16 @@ ChunkCanBeRoot(struct chunk *c);
void Debug_Chunk(struct chunk *);
void Free_Chunk(struct chunk *);
struct chunk * Clone_Chunk(struct chunk *);
-int Add_Chunk(struct disk *, long , u_long , char *, chunk_e, int , u_long);
+int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long);
void Bios_Limit_Chunk(struct chunk *, u_long);
-void * read_block(int, daddr_t );
+void * read_block(int, daddr_t);
void write_block(int fd, daddr_t block, void *foo);
struct disklabel * read_disklabel(int, daddr_t);
u_short dkcksum(struct disklabel *);
-struct chunk * Find_Mother_Chunk(struct chunk *, u_long , u_long , chunk_e);
-struct disk * Int_Open_Disk(char *name, u_long size);
+struct chunk * Find_Mother_Chunk(struct chunk *, u_long, u_long, chunk_e);
+struct disk * Int_Open_Disk(const char *name, u_long size);
void Fixup_Names(struct disk *);
+__END_DECLS
#define dprintf printf
diff --git a/lib/libdisk/tst01.c b/lib/libdisk/tst01.c
index 76e479b..78da1010 100644
--- a/lib/libdisk/tst01.c
+++ b/lib/libdisk/tst01.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: tst01.c,v 1.15.2.1 1995/09/20 10:43:04 jkh Exp $
+ * $Id: tst01.c,v 1.16 1995/12/07 10:33:25 peter Exp $
*
*/
@@ -269,7 +269,6 @@ main(int argc, char **argv)
continue;
}
if (!strcasecmp(*cmds,"boot")) {
- extern u_char boot1[],boot2[];
Set_Boot_Blocks(d,boot1,boot2);
continue;
}
OpenPOWER on IntegriCloud