Page MenuHomeFreeBSD

D1401.diff
No OneTemporary

D1401.diff

Index: sbin/fsck_ffs/setup.c
===================================================================
--- sbin/fsck_ffs/setup.c
+++ sbin/fsck_ffs/setup.c
@@ -59,8 +59,6 @@
#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
static void badsb(int listerr, const char *s);
-static int calcsb(char *dev, int devfd, struct fs *fs);
-static struct disklabel *getdisklabel(char *s, int fd);
/*
* Read in a superblock finding an alternate if necessary.
@@ -178,7 +176,7 @@
*/
if (readsb(1) == 0) {
skipclean = 0;
- if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
+ if (bflag || preen)
return(0);
if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
return (0);
@@ -448,89 +446,5 @@
asblk.b_un.b_buf = Malloc(SBLOCKSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
- if ((lp = getdisklabel(NULL, fsreadfd)))
- real_dev_bsize = dev_bsize = secsize = lp->d_secsize;
- else
- dev_bsize = secsize = DEV_BSIZE;
+ dev_bsize = secsize = DEV_BSIZE;
}
-
-/*
- * Calculate a prototype superblock based on information in the disk label.
- * When done the cgsblock macro can be calculated and the fs_ncg field
- * can be used. Do NOT attempt to use other macros without verifying that
- * their needed information is available!
- */
-static int
-calcsb(char *dev, int devfd, struct fs *fs)
-{
- struct disklabel *lp;
- struct partition *pp;
- char *cp;
- int i, nspf;
-
- cp = strchr(dev, '\0') - 1;
- if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
- pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
- return (0);
- }
- lp = getdisklabel(dev, devfd);
- if (isdigit(*cp))
- pp = &lp->d_partitions[0];
- else
- pp = &lp->d_partitions[*cp - 'a'];
- if (pp->p_fstype != FS_BSDFFS) {
- pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n",
- dev, pp->p_fstype < FSMAXTYPES ?
- fstypenames[pp->p_fstype] : "unknown");
- return (0);
- }
- if (pp->p_fsize == 0 || pp->p_frag == 0 ||
- pp->p_cpg == 0 || pp->p_size == 0) {
- pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
- dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
- pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
- return (0);
- }
- memset(fs, 0, sizeof(struct fs));
- fs->fs_fsize = pp->p_fsize;
- fs->fs_frag = pp->p_frag;
- fs->fs_size = pp->p_size;
- fs->fs_sblkno = roundup(
- howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize),
- fs->fs_frag);
- nspf = fs->fs_fsize / lp->d_secsize;
- for (fs->fs_fsbtodb = 0, i = nspf; i > 1; i >>= 1)
- fs->fs_fsbtodb++;
- dev_bsize = lp->d_secsize;
- if (fs->fs_magic == FS_UFS2_MAGIC) {
- fs->fs_fpg = pp->p_cpg;
- fs->fs_ncg = howmany(fs->fs_size, fs->fs_fpg);
- } else /* if (fs->fs_magic == FS_UFS1_MAGIC) */ {
- fs->fs_old_cpg = pp->p_cpg;
- fs->fs_old_cgmask = 0xffffffff;
- for (i = lp->d_ntracks; i > 1; i >>= 1)
- fs->fs_old_cgmask <<= 1;
- if (!POWEROF2(lp->d_ntracks))
- fs->fs_old_cgmask <<= 1;
- fs->fs_old_cgoffset = roundup(howmany(lp->d_nsectors, nspf),
- fs->fs_frag);
- fs->fs_fpg = (fs->fs_old_cpg * lp->d_secpercyl) / nspf;
- fs->fs_ncg = howmany(fs->fs_size / lp->d_secpercyl,
- fs->fs_old_cpg);
- }
- return (1);
-}
-
-static struct disklabel *
-getdisklabel(char *s, int fd)
-{
- static struct disklabel lab;
-
- if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
- if (s == NULL)
- return ((struct disklabel *)NULL);
- pwarn("ioctl (GCINFO): %s\n", strerror(errno));
- errx(EEXIT, "%s: can't read disk label", s);
- }
- return (&lab);
-}
Index: sbin/fsirand/fsirand.c
===================================================================
--- sbin/fsirand/fsirand.c
+++ sbin/fsirand/fsirand.c
@@ -127,15 +127,6 @@
return (1);
}
- /* Get block size (usually 512) from disklabel if possible */
- if (!ignorelabel) {
- if (ioctl(devfd, DIOCGDINFO, &label) < 0)
- warn("can't read disklabel, using sector size of %d",
- bsize);
- else
- bsize = label.d_secsize;
- }
-
dp1 = NULL;
dp2 = NULL;
Index: sbin/newfs/newfs.c
===================================================================
--- sbin/newfs/newfs.c
+++ sbin/newfs/newfs.c
@@ -117,11 +117,9 @@
static int is_file; /* work on a file, not a device */
static char *dkname;
static char *disktype;
-static int unlabeled;
static void getfssize(intmax_t *, const char *p, intmax_t, intmax_t);
static struct disklabel *getdisklabel(char *s);
-static void rewritelabel(char *s, struct disklabel *lp);
static void usage(void);
static int expand_number_int(const char *buf, int *num);
@@ -402,12 +400,6 @@
pp->p_size *= secperblk;
}
mkfs(pp, special);
- if (!unlabeled) {
- if (realsectorsize != DEV_BSIZE)
- pp->p_size /= realsectorsize / DEV_BSIZE;
- if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition)))
- rewritelabel(special, lp);
- }
ufs_disk_close(&disk);
if (!jflag)
exit(0);
@@ -451,9 +443,6 @@
return &lab;
}
- if (ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab) != -1)
- return (&lab);
- unlabeled++;
if (disktype) {
lp = getdiskbyname(disktype);
if (lp != NULL)
@@ -462,25 +451,6 @@
return (NULL);
}
-void
-rewritelabel(char *s, struct disklabel *lp)
-{
- if (unlabeled)
- return;
- lp->d_checksum = 0;
- lp->d_checksum = dkcksum(lp);
- if (is_file) {
- bsd_disklabel_le_enc(bootarea + 0 /* labeloffset */ +
- 1 /* labelsoffset */ * sectorsize, lp);
- lseek(disk.d_fd, 0, SEEK_SET);
- if (write(disk.d_fd, bootarea, BBSIZE) != BBSIZE)
- errx(1, "cannot write label");
- return;
- }
- if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) == -1)
- warn("ioctl (WDINFO): %s: can't rewrite disk label", s);
-}
-
static void
usage()
{
Index: sbin/newfs_msdos/newfs_msdos.c
===================================================================
--- sbin/newfs_msdos/newfs_msdos.c
+++ sbin/newfs_msdos/newfs_msdos.c
@@ -829,28 +829,26 @@
if (lp == NULL) {
if (bpb->bpbBytesPerSec)
dlp.d_secsize = bpb->bpbBytesPerSec;
- if (ioctl(fd, DIOCGDINFO, &dlp) == -1) {
- if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE,
- &dlp.d_secsize) == -1)
- err(1, "cannot get sector size");
+ if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE,
+ &dlp.d_secsize) == -1)
+ err(1, "cannot get sector size");
- dlp.d_secperunit = ms / dlp.d_secsize;
+ dlp.d_secperunit = ms / dlp.d_secsize;
- if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS,
- &dlp.d_nsectors) == -1) {
- warn("cannot get number of sectors per track");
- dlp.d_nsectors = 63;
- }
- if (bpb->bpbHeads == 0 &&
- ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
- warn("cannot get number of heads");
- if (dlp.d_secperunit <= 63*1*1024)
- dlp.d_ntracks = 1;
- else if (dlp.d_secperunit <= 63*16*1024)
- dlp.d_ntracks = 16;
- else
- dlp.d_ntracks = 255;
- }
+ if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS,
+ &dlp.d_nsectors) == -1) {
+ warn("cannot get number of sectors per track");
+ dlp.d_nsectors = 63;
+ }
+ if (bpb->bpbHeads == 0 &&
+ ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
+ warn("cannot get number of heads");
+ if (dlp.d_secperunit <= 63*1*1024)
+ dlp.d_ntracks = 1;
+ else if (dlp.d_secperunit <= 63*16*1024)
+ dlp.d_ntracks = 16;
+ else
+ dlp.d_ntracks = 255;
}
hs = (ms / dlp.d_secsize) - dlp.d_secperunit;
Index: share/man/man4/cd.4
===================================================================
--- share/man/man4/cd.4
+++ share/man/man4/cd.4
@@ -101,16 +101,6 @@
and
.In sys/disklabel.h .
.Bl -tag -width CDIOCREADSUBCHANNEL
-.It Dv DIOCGDINFO
-.It Dv DIOCSDINFO
-.Pq Li "struct disklabel"
-Read or write the in-core copy of the disklabel for the
-drive.
-The disklabel is initialized with information
-read from the scsi inquiry commands, and should be the same as
-the information printed at boot.
-This structure is defined in the header file
-.In sys/disklabel.h .
.It Dv CDIOCPLAYTRACKS
.Pq Li "struct ioc_play_track"
Start audio playback given a track address and length.
Index: share/man/man4/mcd.4
===================================================================
--- share/man/man4/mcd.4
+++ share/man/man4/mcd.4
@@ -56,12 +56,8 @@
driver responds to disk-specific
.Fn ioctl
commands, namely the
-.Dv DIOCGDINFO ,
-.Dv DIOCGPART ,
-.Dv DIOCWDINFO ,
-and
-.Dv DIOCSDINFO ,
-commands.
+.Dv DIOCGPART
+command.
Other disk-specific
.Fn ioctl
commands will return an error.
Index: sys/geom/geom_bsd.c
===================================================================
--- sys/geom/geom_bsd.c
+++ sys/geom/geom_bsd.c
@@ -305,8 +305,8 @@
gsp = gp->softc;
ms = gsp->softc;
gsl = &gsp->slices[bp->bio_to->index];
- p = (u_char*)bp->bio_data + ms->labeloffset
- - (bp->bio_offset + gsl->offset);
+ p = (u_char*)bp->bio_data + ms->labeloffset -
+ (bp->bio_offset + gsl->offset);
error = g_bsd_modify(gp, p);
if (error) {
g_io_deliver(bp, EPERM);
@@ -315,93 +315,6 @@
g_slice_finish_hot(bp);
}
-/*-
- * This start routine is only called for non-trivial requests, all the
- * trivial ones are handled autonomously by the slice code.
- * For requests we handle here, we must call the g_io_deliver() on the
- * bio, and return non-zero to indicate to the slice code that we did so.
- * This code executes in the "DOWN" I/O path, this means:
- * * No sleeping.
- * * Don't grab the topology lock.
- * * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
- */
-static int
-g_bsd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
-{
- struct g_geom *gp;
- struct g_bsd_softc *ms;
- struct g_slicer *gsp;
- u_char *label;
- int error;
-
- gp = pp->geom;
- gsp = gp->softc;
- ms = gsp->softc;
-
- switch(cmd) {
- case DIOCGDINFO:
- /* Return a copy of the disklabel to userland. */
- bsd_disklabel_le_dec(ms->label, data, MAXPARTITIONS);
- return(0);
- case DIOCBSDBB: {
- struct g_consumer *cp;
- u_char *buf;
- void *p;
- int error, i;
- uint64_t sum;
-
- if (!(fflag & FWRITE))
- return (EPERM);
- /* The disklabel to set is the ioctl argument. */
- buf = g_malloc(BBSIZE, M_WAITOK);
- p = *(void **)data;
- error = copyin(p, buf, BBSIZE);
- if (!error) {
- /* XXX: Rude, but supposedly safe */
- DROP_GIANT();
- g_topology_lock();
- /* Validate and modify our slice instance to match. */
- error = g_bsd_modify(gp, buf + ms->labeloffset);
- if (!error) {
- cp = LIST_FIRST(&gp->consumer);
- if (ms->labeloffset == ALPHA_LABEL_OFFSET) {
- sum = 0;
- for (i = 0; i < 63; i++)
- sum += le64dec(buf + i * 8);
- le64enc(buf + 504, sum);
- }
- error = g_write_data(cp, 0, buf, BBSIZE);
- }
- g_topology_unlock();
- PICKUP_GIANT();
- }
- g_free(buf);
- return (error);
- }
- case DIOCSDINFO:
- case DIOCWDINFO: {
- if (!(fflag & FWRITE))
- return (EPERM);
- label = g_malloc(LABELSIZE, M_WAITOK);
- /* The disklabel to set is the ioctl argument. */
- bsd_disklabel_le_enc(label, data);
-
- DROP_GIANT();
- g_topology_lock();
- /* Validate and modify our slice instance to match. */
- error = g_bsd_modify(gp, label);
- if (error == 0 && cmd == DIOCWDINFO)
- error = g_bsd_writelabel(gp, NULL);
- g_topology_unlock();
- PICKUP_GIANT();
- g_free(label);
- return(error);
- }
- default:
- return (ENOIOCTL);
- }
-}
-
static int
g_bsd_start(struct bio *bp)
{
@@ -698,7 +611,6 @@
.taste = g_bsd_taste,
.ctlreq = g_bsd_config,
.dumpconf = g_bsd_dumpconf,
- .ioctl = g_bsd_ioctl,
};
DECLARE_GEOM_CLASS(g_bsd_class, g_bsd);
Index: sys/geom/part/g_part_bsd.c
===================================================================
--- sys/geom/part/g_part_bsd.c
+++ sys/geom/part/g_part_bsd.c
@@ -83,8 +83,6 @@
static int g_part_bsd_write(struct g_part_table *, struct g_consumer *);
static int g_part_bsd_resize(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
-static int g_part_bsd_ioctl(struct g_part_table *, struct g_provider *,
- u_long cmd, void *data, int fflag, struct thread *td);
static kobj_method_t g_part_bsd_methods[] = {
KOBJMETHOD(g_part_add, g_part_bsd_add),
@@ -100,7 +98,6 @@
KOBJMETHOD(g_part_read, g_part_bsd_read),
KOBJMETHOD(g_part_type, g_part_bsd_type),
KOBJMETHOD(g_part_write, g_part_bsd_write),
- KOBJMETHOD(g_part_ioctl, g_part_bsd_ioctl),
{ 0, 0 }
};
@@ -497,38 +494,6 @@
return (buf);
}
-/*-
- * This start routine is only called for non-trivial requests, all the
- * trivial ones are handled autonomously by the slice code.
- * For requests we handle here, we must call the g_io_deliver() on the
- * bio, and return non-zero to indicate to the slice code that we did so.
- * This code executes in the "DOWN" I/O path, this means:
- * * No sleeping.
- * * Don't grab the topology lock.
- * * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
- */
-static int
-g_part_bsd_ioctl(struct g_part_table *basetable, struct g_provider *pp,
- u_long cmd, void *data, int fflag, struct thread *td)
-{
-
- switch (cmd)
- {
- case DIOCGDINFO:
- {
- struct g_part_bsd_table *table;
- u_char *p;
-
- table = (struct g_part_bsd_table *)basetable;
- p = table->bbarea + pp->sectorsize;
- return (bsd_disklabel_le_dec(p, data, MAXPARTITIONS));
- }
- default:
- return (ENOIOCTL);
-
- }
-}
-
static int
g_part_bsd_write(struct g_part_table *basetable, struct g_consumer *cp)
{
Index: sys/sys/disklabel.h
===================================================================
--- sys/sys/disklabel.h
+++ sys/sys/disklabel.h
@@ -284,15 +284,8 @@
#define D_CHAIN 0x10 /* can do back-back transfers */
/*
- * Disklabel-specific ioctls.
- *
* NB: <sys/disk.h> defines ioctls from 'd'/128 and up.
*/
- /* get and set disklabel */
-#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */
-#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */
-#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */
-#define DIOCBSDBB _IOW('d', 110, void *) /* write bootblocks */
/*
* Functions for proper encoding/decoding of struct disklabel into/from

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 28, 5:58 PM (12 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26292961
Default Alt Text
D1401.diff (13 KB)

Event Timeline