summaryrefslogtreecommitdiffstats
path: root/lib/libdisk/libdisk.h
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>2001-05-13 20:08:54 +0000
committerjkh <jkh@FreeBSD.org>2001-05-13 20:08:54 +0000
commit5b33a2af7cc4f8e49951b70e1fc5b616876450a6 (patch)
treeac04e3b0eea5f057863e3c3ee8b4637d07f2adb8 /lib/libdisk/libdisk.h
parentc6db5e77fc9682b938a8776c6e2c8cbda527cd2c (diff)
downloadFreeBSD-src-5b33a2af7cc4f8e49951b70e1fc5b616876450a6.zip
FreeBSD-src-5b33a2af7cc4f8e49951b70e1fc5b616876450a6.tar.gz
+ add u_long sector_size to struct disk (documented in libdisk.3)
+ make Open_Disk sense the sector size by trying 512, 1024 and 2048 in this order. This makes the kernel note that dscheck(cd1): bio_bcount 512 is not on a sector boundary (ssize 2048) dscheck(cd1): bio_bcount 1024 is not on a sector boundary (ssize 2048) if 2048 is the sector size. If this worries anyone: the message is from /usr/src/sys/kern/subr_diskslice.c and shutups are to be placed there. + Have read_block and write_block use an additional parameter, the sector size. + replace all barfout calls with return NULL, 0, __LINE__, etc. Note that this does NOT emit diagnostics. More often than not, you don't want library functions to scribble on stderr -- it may not even be available. The right thing is to propagate the error condition to upper management. The app should take care of errors. + use d1->sector_size instead of 512 in various places. I've left many places untouched, especially those writing MBRs. I simply added another arg hardcoded as 512. This is because I would not know what I'm doing... I felt this approach would be reasonably backward compatible and not introduce any new bugs in critical software. Famous last words. Messing with MBRs might soon put me in the same screwup meister category as, uh, never mind. :-) + bump the max no of disks from 20 to 32 (due to PR 24503). PR: 8434 / 8436 / 24503 Submitted by: Jens Schweikhardt <schweikh@schweikhardt.net>
Diffstat (limited to 'lib/libdisk/libdisk.h')
-rw-r--r--lib/libdisk/libdisk.h26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index 842bb50..9457dfb 100644
--- a/lib/libdisk/libdisk.h
+++ b/lib/libdisk/libdisk.h
@@ -10,17 +10,12 @@
*
*/
-#ifdef __i386__
-#include <err.h>
-#define barfout(n, errstr) err(n, errstr)
-#else
-#include <stdio.h>
-#define barfout(n, errstr) fprintf(stderr, "\n\n\t***[ %s ]***\t\n\n", errstr)
-#endif
-
-#define MAX_NO_DISKS 20
+#define MAX_NO_DISKS 32
/* Max # of disks Disk_Names() will return */
+#define MAX_SEC_SIZE 2048 /* maximum sector size that is supported */
+#define MIN_SEC_SIZE 512 /* the sector size to end sensing at */
+
typedef enum {
whole,
unknown,
@@ -53,6 +48,7 @@ struct disk {
u_char *boot2;
#endif
struct chunk *chunks;
+ u_long sector_size; /* media sector size, a power of 2 */
};
struct chunk {
@@ -190,10 +186,10 @@ Set_Boot_Mgr(struct disk *d, const u_char *bootmgr, const size_t bootmgr_size);
* is called
*/
-void
+int
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
+ * is called. Returns nonzero upon failure.
*/
int
@@ -270,12 +266,12 @@ int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long, c
#else
int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long);
#endif
-void * read_block(int, daddr_t);
-void write_block(int fd, daddr_t block, void *foo);
-struct disklabel * read_disklabel(int, daddr_t);
+void * read_block(int, daddr_t, u_long);
+int write_block(int, daddr_t, void *, u_long);
+struct disklabel * read_disklabel(int, daddr_t, u_long);
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 *);
+int Fixup_Names(struct disk *);
__END_DECLS
#define dprintf printf
OpenPOWER on IntegriCloud