Date: Thu, 24 Aug 2017 21:44:23 +0000 (UTC) From: Kirk McKusick <mckusick@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322860 - in stable/10: sbin/fsck_ffs sbin/fsirand sbin/newfs sbin/newfs_msdos share/man/man4 sys/geom sys/sys sys/ufs/ffs Message-ID: <201708242144.v7OLiNSI002175@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mckusick Date: Thu Aug 24 21:44:23 2017 New Revision: 322860 URL: https://svnweb.freebsd.org/changeset/base/322860 Log: MFC of 276737, 322200, 322201, 322271, and 322297 276737: Remove old ioctl use and support 322200: Remove (broken) search for alternate superblocks 322201: Show differences when alternate superblock fails to match 322271: Cleanup for 322200. 322297: Restore fsck_ffs ability to find alternate superblocks Discussed with: kib, imp Differential Revision: https://reviews.freebsd.org/D11589 Approved by: re (kib) Modified: stable/10/sbin/fsck_ffs/setup.c stable/10/sbin/fsirand/fsirand.c stable/10/sbin/newfs/mkfs.c stable/10/sbin/newfs/newfs.c stable/10/sbin/newfs_msdos/newfs_msdos.c stable/10/share/man/man4/cd.4 stable/10/share/man/man4/mcd.4 stable/10/sys/geom/geom_bsd.c stable/10/sys/sys/disklabel.h stable/10/sys/ufs/ffs/fs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fsck_ffs/setup.c ============================================================================== --- stable/10/sbin/fsck_ffs/setup.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/fsck_ffs/setup.c Thu Aug 24 21:44:23 2017 (r322860) @@ -58,9 +58,9 @@ struct bufarea asblk; #define altsblock (*asblk.b_un.b_fs) #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); +static void saverecovery(int readfd, int writefd); +static int chkrecovery(int devfd); /* * Read in a superblock finding an alternate if necessary. @@ -236,6 +236,10 @@ setup(char *dev) memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize); flush(fswritefd, &asblk); } + if (preen == 0 && yflag == 0 && sblock.fs_magic == FS_UFS2_MAGIC && + fswritefd != -1 && chkrecovery(fsreadfd) == 0 && + reply("SAVE DATA TO FIND ALTERNATE SUPERBLOCKS") != 0) + saverecovery(fsreadfd, fswritefd); /* * read in the summary info. */ @@ -319,7 +323,7 @@ int readsb(int listerr) { ufs2_daddr_t super; - int i; + int i, bad; if (bflag) { super = bflag; @@ -369,40 +373,57 @@ readsb(int listerr) dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1); sblk.b_bno = super / dev_bsize; sblk.b_size = SBLOCKSIZE; - if (bflag) - goto out; /* * Compare all fields that should not differ in alternate super block. * When an alternate super-block is specified this check is skipped. */ + if (bflag) + goto out; getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize); if (asblk.b_errs) return (0); - if (altsblock.fs_sblkno != sblock.fs_sblkno || - altsblock.fs_cblkno != sblock.fs_cblkno || - altsblock.fs_iblkno != sblock.fs_iblkno || - altsblock.fs_dblkno != sblock.fs_dblkno || - altsblock.fs_ncg != sblock.fs_ncg || - altsblock.fs_bsize != sblock.fs_bsize || - altsblock.fs_fsize != sblock.fs_fsize || - altsblock.fs_frag != sblock.fs_frag || - altsblock.fs_bmask != sblock.fs_bmask || - altsblock.fs_fmask != sblock.fs_fmask || - altsblock.fs_bshift != sblock.fs_bshift || - altsblock.fs_fshift != sblock.fs_fshift || - altsblock.fs_fragshift != sblock.fs_fragshift || - altsblock.fs_fsbtodb != sblock.fs_fsbtodb || - altsblock.fs_sbsize != sblock.fs_sbsize || - altsblock.fs_nindir != sblock.fs_nindir || - altsblock.fs_inopb != sblock.fs_inopb || - altsblock.fs_cssize != sblock.fs_cssize || - altsblock.fs_ipg != sblock.fs_ipg || - altsblock.fs_fpg != sblock.fs_fpg || - altsblock.fs_magic != sblock.fs_magic) { - badsb(listerr, - "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE"); - return (0); + bad = 0; +#define CHK(x, y) \ + if (altsblock.x != sblock.x) { \ + bad++; \ + if (listerr && debug) \ + printf("SUPER BLOCK VS ALTERNATE MISMATCH %s: " y " vs " y "\n", \ + #x, (intmax_t)sblock.x, (intmax_t)altsblock.x); \ } + CHK(fs_sblkno, "%jd"); + CHK(fs_cblkno, "%jd"); + CHK(fs_iblkno, "%jd"); + CHK(fs_dblkno, "%jd"); + CHK(fs_ncg, "%jd"); + CHK(fs_bsize, "%jd"); + CHK(fs_fsize, "%jd"); + CHK(fs_frag, "%jd"); + CHK(fs_bmask, "%#jx"); + CHK(fs_fmask, "%#jx"); + CHK(fs_bshift, "%jd"); + CHK(fs_fshift, "%jd"); + CHK(fs_fragshift, "%jd"); + CHK(fs_fsbtodb, "%jd"); + CHK(fs_sbsize, "%jd"); + CHK(fs_nindir, "%jd"); + CHK(fs_inopb, "%jd"); + CHK(fs_cssize, "%jd"); + CHK(fs_ipg, "%jd"); + CHK(fs_fpg, "%jd"); + CHK(fs_magic, "%#jx"); +#undef CHK + if (bad) { + if (listerr == 0) + return (0); + if (preen) + printf("%s: ", cdevname); + printf( + "VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n" + "LAST ALTERNATE LSB=%jd\n", + sblk.b_bno, asblk.b_bno); + if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0) + return (0); + } out: /* * If not yet done, update UFS1 superblock with new wider fields. @@ -423,21 +444,9 @@ out: return (1); } -static void -badsb(int listerr, const char *s) -{ - - if (!listerr) - return; - if (preen) - printf("%s: ", cdevname); - pfatal("BAD SUPER BLOCK: %s\n", s); -} - void sblock_init(void) { - struct disklabel *lp; fswritefd = -1; fsmodified = 0; @@ -448,14 +457,11 @@ sblock_init(void) 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. + * Calculate a prototype superblock based on information in the boot area. * 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! @@ -463,74 +469,63 @@ sblock_init(void) static int calcsb(char *dev, int devfd, struct fs *fs) { - struct disklabel *lp; - struct partition *pp; - char *cp; - int i, nspf; + struct fsrecovery fsr; - 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); + /* + * We need fragments-per-group and the partition-size. + * + * Newfs stores these details at the end of the boot block area + * at the start of the filesystem partition. If they have been + * overwritten by a boot block, we fail. But usually they are + * there and we can use them. + */ + if (blread(devfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr)) || + fsr.fsr_magic != FS_UFS2_MAGIC) 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); - } + fs->fs_fpg = fsr.fsr_fpg; + fs->fs_fsbtodb = fsr.fsr_fsbtodb; + fs->fs_sblkno = fsr.fsr_sblkno; + fs->fs_magic = fsr.fsr_magic; + fs->fs_ncg = fsr.fsr_ncg; return (1); } -static struct disklabel * -getdisklabel(char *s, int fd) +/* + * Check to see if recovery information exists. + */ +static int +chkrecovery(int devfd) { - static struct disklabel lab; + struct fsrecovery fsr; - 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); + if (blread(devfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr)) || + fsr.fsr_magic != FS_UFS2_MAGIC) + return (0); + return (1); +} + +/* + * Read the last sector of the boot block, replace the last + * 20 bytes with the recovery information, then write it back. + * The recovery information only works for UFS2 filesystems. + */ +static void +saverecovery(int readfd, int writefd) +{ + struct fsrecovery fsr; + + if (sblock.fs_magic != FS_UFS2_MAGIC || + blread(readfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr))) + return; + fsr.fsr_magic = sblock.fs_magic; + fsr.fsr_fpg = sblock.fs_fpg; + fsr.fsr_fsbtodb = sblock.fs_fsbtodb; + fsr.fsr_sblkno = sblock.fs_sblkno; + fsr.fsr_ncg = sblock.fs_ncg; + blwrite(writefd, (char *)&fsr, (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, + sizeof(fsr)); } Modified: stable/10/sbin/fsirand/fsirand.c ============================================================================== --- stable/10/sbin/fsirand/fsirand.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/fsirand/fsirand.c Thu Aug 24 21:44:23 2017 (r322860) @@ -36,7 +36,6 @@ static const char rcsid[] = #endif /* not lint */ #include <sys/param.h> -#include <sys/disklabel.h> #include <sys/resource.h> #include <ufs/ufs/dinode.h> @@ -120,20 +119,10 @@ fsirand(char *device) char sbuf[SBLOCKSIZE], sbuftmp[SBLOCKSIZE]; int i, devfd, n, cg; u_int32_t bsize = DEV_BSIZE; - struct disklabel label; if ((devfd = open(device, printonly ? O_RDONLY : O_RDWR)) < 0) { warn("can't open %s", device); 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; Modified: stable/10/sbin/newfs/mkfs.c ============================================================================== --- stable/10/sbin/newfs/mkfs.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/newfs/mkfs.c Thu Aug 24 21:44:23 2017 (r322860) @@ -121,6 +121,7 @@ mkfs(struct partition *pp, char *fsys) ino_t maxinum; int minfragsperinode; /* minimum ratio of frags to inodes */ char tmpbuf[100]; /* XXX this will break in about 2,500 years */ + struct fsrecovery fsr; union { struct fs fdummy; char cdummy[SBLOCKSIZE]; @@ -618,6 +619,25 @@ restart: sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize, ((char *)fscs) + i); + /* + * Read the last sector of the boot block, replace the last + * 20 bytes with the recovery information, then write it back. + * The recovery information only works for UFS2 filesystems. + */ + if (sblock.fs_magic == FS_UFS2_MAGIC) { + i = bread(&disk, + part_ofs + (SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize, + (char *)&fsr, sizeof(fsr)); + if (i == -1) + err(1, "can't read recovery area: %s", disk.d_error); + fsr.fsr_magic = sblock.fs_magic; + fsr.fsr_fpg = sblock.fs_fpg; + fsr.fsr_fsbtodb = sblock.fs_fsbtodb; + fsr.fsr_sblkno = sblock.fs_sblkno; + fsr.fsr_ncg = sblock.fs_ncg; + wtfs((SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize, sizeof(fsr), + (char *)&fsr); + } /* * Update information about this partition in pack * label, to that it may be updated on disk. Modified: stable/10/sbin/newfs/newfs.c ============================================================================== --- stable/10/sbin/newfs/newfs.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/newfs/newfs.c Thu Aug 24 21:44:23 2017 (r322860) @@ -117,11 +117,9 @@ static u_char bootarea[BBSIZE]; 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); @@ -403,12 +401,6 @@ main(int argc, char *argv[]) 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); @@ -452,34 +444,12 @@ getdisklabel(char *s) return &lab; } - if (ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab) != -1) - return (&lab); - unlabeled++; if (disktype) { lp = getdiskbyname(disktype); if (lp != NULL) return (lp); } 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 Modified: stable/10/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/10/sbin/newfs_msdos/newfs_msdos.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/newfs_msdos/newfs_msdos.c Thu Aug 24 21:44:23 2017 (r322860) @@ -829,28 +829,26 @@ getdiskinfo(int fd, const char *fname, const char *dty 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; Modified: stable/10/share/man/man4/cd.4 ============================================================================== --- stable/10/share/man/man4/cd.4 Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/share/man/man4/cd.4 Thu Aug 24 21:44:23 2017 (r322860) @@ -101,16 +101,6 @@ in the header files 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. Modified: stable/10/share/man/man4/mcd.4 ============================================================================== --- stable/10/share/man/man4/mcd.4 Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/share/man/man4/mcd.4 Thu Aug 24 21:44:23 2017 (r322860) @@ -61,12 +61,8 @@ The 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. Modified: stable/10/sys/geom/geom_bsd.c ============================================================================== --- stable/10/sys/geom/geom_bsd.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sys/geom/geom_bsd.c Thu Aug 24 21:44:23 2017 (r322860) @@ -305,8 +305,8 @@ g_bsd_hotwrite(void *arg, int flag) 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,94 +315,7 @@ g_bsd_hotwrite(void *arg, int flag) 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) { struct g_geom *gp; @@ -698,7 +611,6 @@ static struct g_class g_bsd_class = { .taste = g_bsd_taste, .ctlreq = g_bsd_config, .dumpconf = g_bsd_dumpconf, - .ioctl = g_bsd_ioctl, }; DECLARE_GEOM_CLASS(g_bsd_class, g_bsd); Modified: stable/10/sys/sys/disklabel.h ============================================================================== --- stable/10/sys/sys/disklabel.h Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sys/sys/disklabel.h Thu Aug 24 21:44:23 2017 (r322860) @@ -284,15 +284,8 @@ static const char *fstypenames[] = { #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 Modified: stable/10/sys/ufs/ffs/fs.h ============================================================================== --- stable/10/sys/ufs/ffs/fs.h Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sys/ufs/ffs/fs.h Thu Aug 24 21:44:23 2017 (r322860) @@ -234,6 +234,20 @@ struct fsck_cmd { }; /* + * A recovery structure placed at the end of the boot block area by newfs + * that can be used by fsck to search for alternate superblocks. + */ +#define RESID (4096 - 20) /* disk sector size minus recovery area size */ +struct fsrecovery { + char block[RESID]; /* unused part of sector */ + int32_t fsr_magic; /* magic number */ + int32_t fsr_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fsr_sblkno; /* offset of super-block in filesys */ + int32_t fsr_fpg; /* blocks per group * fs_frag */ + u_int32_t fsr_ncg; /* number of cylinder groups */ +}; + +/* * Per cylinder group information; summarized in blocks allocated * from first cylinder group data blocks. These blocks have to be * read in from fs_csaddr (size fs_cssize) in addition to the
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708242144.v7OLiNSI002175>