more disklabel changes

This commit is contained in:
deraadt 1993-05-20 23:12:53 +00:00
parent e34f239662
commit 6fb28b3c74
5 changed files with 51 additions and 30 deletions

View File

@ -13,7 +13,7 @@
* on the understanding that TFS is not responsible for the correct
* functioning of this software in any circumstances.
*
* $Id: sd.c,v 1.9 1993/05/20 03:46:42 cgd Exp $
* $Id: sd.c,v 1.10 1993/05/20 23:12:53 deraadt Exp $
*/
#include "sd.h"
@ -601,6 +601,7 @@ sdioctl(dev_t dev, int cmd, caddr_t addr, int flag)
{
/* struct sd_cmd_buf *args;*/
struct scsi_format_parms *fparms;
struct cpu_disklabel osdep;
extern struct proc *curproc;
register struct sd_data *sd;
unsigned char unit, part;
@ -676,7 +677,7 @@ unlock:
else {
error = setdisklabel(&sd->disklabel, (struct disklabel *)addr,
/*(sd->flags & DKFL_BSDLABEL) ? sd->openparts : */0,
sd->dosparts);
&sd->cpudisklabel);
}
if (error == 0)
sd->flags |= SDHAVELABEL;
@ -696,7 +697,7 @@ unlock:
if ((error = setdisklabel(&sd->disklabel,
(struct disklabel *)addr,
/*(sd->flags & SDHAVELABEL) ? sd->openparts :*/0,
sd->dosparts)) == 0) {
&sd->cpudisklabel)) == 0) {
int wlab;
sd->flags |= SDHAVELABEL; /* ok write will succeed */
@ -706,7 +707,7 @@ unlock:
wlab = sd->wlabel;
sd->wlabel = 1;
error = writedisklabel(dev, sdstrategy,
&sd->disklabel, sd->dosparts);
&sd->disklabel, &sd->cpudisklabel);
sd->wlabel = wlab;
}
}
@ -725,10 +726,10 @@ unlock:
int
sdgetdisklabel(u_char unit)
{
struct dos_partition *dos_partition_p;
struct sd_data *sd = sd_data[unit];
/*unsigned int n, m;*/
char *errstring;
struct cpu_disklabel osdep;
/* If the inflo is already loaded, use it */
if(sd->flags & SDHAVELABEL)
@ -756,7 +757,7 @@ sdgetdisklabel(u_char unit)
/* all the generic disklabel extraction routine */
if(errstring = readdisklabel(makedev(0 ,(unit<<UNITSHIFT )+3),
sdstrategy, &sd->disklabel, sd->dosparts, 0, 0)) {
sdstrategy, &sd->disklabel, &sd->cpudisklabel)) {
printf("sd%d: %s\n",unit, errstring);
return ENXIO;
}

View File

@ -1 +1 @@
revision 1.2 intentionally removed
revision 1.3 intentionally removed

View File

@ -13,7 +13,7 @@
* on the understanding that TFS is not responsible for the correct
* functioning of this software in any circumstances.
*
* $Id: sd.c,v 1.9 1993/05/20 03:46:42 cgd Exp $
* $Id: sd.c,v 1.10 1993/05/20 23:12:53 deraadt Exp $
*/
#include "sd.h"
@ -601,6 +601,7 @@ sdioctl(dev_t dev, int cmd, caddr_t addr, int flag)
{
/* struct sd_cmd_buf *args;*/
struct scsi_format_parms *fparms;
struct cpu_disklabel osdep;
extern struct proc *curproc;
register struct sd_data *sd;
unsigned char unit, part;
@ -676,7 +677,7 @@ unlock:
else {
error = setdisklabel(&sd->disklabel, (struct disklabel *)addr,
/*(sd->flags & DKFL_BSDLABEL) ? sd->openparts : */0,
sd->dosparts);
&sd->cpudisklabel);
}
if (error == 0)
sd->flags |= SDHAVELABEL;
@ -696,7 +697,7 @@ unlock:
if ((error = setdisklabel(&sd->disklabel,
(struct disklabel *)addr,
/*(sd->flags & SDHAVELABEL) ? sd->openparts :*/0,
sd->dosparts)) == 0) {
&sd->cpudisklabel)) == 0) {
int wlab;
sd->flags |= SDHAVELABEL; /* ok write will succeed */
@ -706,7 +707,7 @@ unlock:
wlab = sd->wlabel;
sd->wlabel = 1;
error = writedisklabel(dev, sdstrategy,
&sd->disklabel, sd->dosparts);
&sd->disklabel, &sd->cpudisklabel);
sd->wlabel = wlab;
}
}
@ -725,10 +726,10 @@ unlock:
int
sdgetdisklabel(u_char unit)
{
struct dos_partition *dos_partition_p;
struct sd_data *sd = sd_data[unit];
/*unsigned int n, m;*/
char *errstring;
struct cpu_disklabel osdep;
/* If the inflo is already loaded, use it */
if(sd->flags & SDHAVELABEL)
@ -756,7 +757,7 @@ sdgetdisklabel(u_char unit)
/* all the generic disklabel extraction routine */
if(errstring = readdisklabel(makedev(0 ,(unit<<UNITSHIFT )+3),
sdstrategy, &sd->disklabel, sd->dosparts, 0, 0)) {
sdstrategy, &sd->disklabel, &sd->cpudisklabel)) {
printf("sd%d: %s\n",unit, errstring);
return ENXIO;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: sddefs.h,v 1.3 1993/05/20 03:46:46 cgd Exp $
* $Id: sddefs.h,v 1.4 1993/05/20 23:14:22 deraadt Exp $
*/
struct sd_data {
@ -8,7 +8,7 @@ struct sd_data {
#define SDINIT 0x04 /* device has been init'd */
#define SDWAIT 0x08 /* device has someone waiting */
#define SDHAVELABEL 0x10 /* have read the label */
#define SDDOSPART 0x20 /* Have read the DOS partition table */
#define SDDOSPART 0x20 /* Have read host-dependent partition table */
#define SDWRITEPROT 0x40 /* Device in readonly mode (S/W)*/
struct scsi_switch *sc_sw; /* address of scsi low level switch */
struct scsi_xfer *freexfer; /* chain of free ones */
@ -27,9 +27,9 @@ struct sd_data {
u_short secsiz; /* Number of bytes/sector */
u_long disksize; /* total number sectors */
} params;
unsigned int sd_start_of_unix; /* unix vs dos partitions */
unsigned int sd_start_of_unix; /* unix vs host-dependent partitions */
struct disklabel disklabel;
struct dos_partition dosparts[NDOSPART]; /* DOS view of disk */
struct cpu_disklabel cpudisklabel;
int partflags[MAXPARTITIONS]; /* per partition flags */
#define SDOPEN 0x01
int openparts; /* one bit for each open partition */

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)disklabel.h 7.19 (Berkeley) 5/7/91
* $Id: disklabel.h,v 1.3 1993/05/20 16:22:01 cgd Exp $
* $Id: disklabel.h,v 1.4 1993/05/20 23:14:55 deraadt Exp $
*/
#ifndef _SYS_DISKLABEL_H_
@ -294,6 +294,7 @@ struct partinfo {
struct partition *part;
};
#ifdef i386
/* DOS partition table -- located in boot block */
#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
@ -314,6 +315,18 @@ struct dos_partition {
unsigned long dp_size; /* partition size in sectors */
} dos_partitions[NDOSPART];
struct cpu_disklabel {
struct dos_partition dosparts[NDOSPART];
struct dkbad bad;
};
#endif /* i386 */
#if defined(hp300) || defined(mac) || defined(vax)
struct cpu_disklabel {
};
#endif
#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */
#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
@ -338,23 +351,29 @@ struct dos_partition {
#if defined(KERNEL)
#ifdef i386
int bounds_check_with_label __P((struct buf *, struct disklabel *, int));
#endif
void diskerr(struct buf *, char *, char *, int, int, struct disklabel *);
void diskerr __P((struct buf *, char *, char *, int, int, struct disklabel *));
void disksort __P((struct buf *, struct buf *));
int dkcksum __P((struct disklabel *));
int dkcksum(struct disklabel *);
int setdisklabel __P((struct disklabel *, struct disklabel *, u_long,
struct cpu_disklabel *));
int cpu_setdisklabel __P((struct disklabel *, struct disklabel *, u_long,
struct cpu_disklabel *));
int setdisklabel(struct disklabel *, struct disklabel *, u_long,
struct dos_partition *);
char *readdisklabel __P((int, int (*)(), struct disklabel *,
struct cpu_disklabel *));
char *cpu_readdisklabel __P((int, int (*)(), struct disklabel *,
struct cpu_disklabel *));
char *readdisklabel(int, int (*)(), struct disklabel *,
struct dos_partition *, struct dkbad *, struct buf **);
int writedisklabel __P((int, int (*)(), struct disklabel *,
struct cpu_disklabel *));
int cpu_writedisklabel __P((int, int (*)(), struct disklabel *,
struct cpu_disklabel *));
void disksort(struct buf *, struct buf *);
int writedisklabel(int, int (*)(), struct disklabel *,
struct dos_partition *);
int bounds_check_with_label(struct buf *, struct disklabel *, int);
#endif
#endif LOCORE