NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/54470: Adapt FFS to work with HP-UX UFS1 variant
>Number: 54470
>Category: kern
>Synopsis: Adapt FFS to work with HP-UX UFS1 variant
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Thu Aug 15 20:35:00 +0000 2019
>Originator: Konrad Schroder
>Release: NetBSD -current 20190815
>Organization:
University of Washington
>Environment:
System: NetBSD apu1c.bastion.coral.washington.edu 9.99.7 NetBSD 9.99.7 (APU1C_GE
NERIC) #13: Thu Aug 15 12:14:59 PDT 2019 root%backup.coral.washington.edu@localhost:/ovar
/src-current/sys/arch/amd64/compile/obj/APU1C_GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
Old HP-UX used a file system called HFS LFN ("Hierarchical File System
with Long File Names"), which was in essence 4.2(?)BSD UFS with a different
magic number and 1k sector size. The patch below allows NetBSD (kernel,
dump, dumpfs and fsck_ffs) to work with a disk image taken from such a
disk. The main changes are
* Recognize the HP-UX magic number and infer that this is a UFS1
with FS_42POSTBLFMT, a different DIRBLKSIZ and certain other quirks.
* Use macros UFS_BTODB(ump, bytes) and UFS_DBTOB(ump, blocks)
instead of btodb abd dbtob, to account for a different sector size.
This does not represent any change for filesystems with the native
sector size of 512. (In fsck_ffs(8) I used the names BTODB and DBTOB.)
* Don't assume that the new superblock fields (fs_cstotal, fs_size,
etc.) have valid data if we are using an old filesystem that doesn't
have them.
* Switch the sense of tests for magic == FS_UFS1_MAGIC to use
magic != FS_UFS2_MAGIC instead, since the HP magic number is different.
(I hope that no one will make a UFS2 variant with a different magic
number, but if that happens we can deal with it then.)
If there are no objections I'll commit this in the next week or two.
>How-To-Repeat:
Try to mount or work with an old HP disk (or disk image) on NetBSD:
# cat > mo.disktab
mo35|Emulated HP 3.5in MO:\
:ty=winchester:dt=SCSI:se#1024:ns#16:nt#64:nc#121:\
:pa#124400:oa#0:ba#8192:fa#1024:ta=4.2BSD:\
:pc#124400:oc#0:bc#0:fc#0:tc=unused:\
:pd#124400:od#0:bd#0:fd#0:td=unused:
# vnconfig -f mo.disktab -t mo35 vnd0 ./mo.img
# mount -t ffs /dev/vnd0d /mnt
mount_ffs: /dev/vnd0d on /mnt: incorrect super block
# fsck_ffs /dev/rvnd0d
** /dev/rvnd0d
BAD SUPER BLOCK: CAN'T FIND SUPERBLOCK
/dev/rvnd0d: NOT LABELED AS A BSD FILE SYSTEM (unused)
# dumpfs /dev/rvnd0d
dumpfs: /dev/rvnd0d: could not find superblock, skipped
# dump -0 -f- /dev/rvnd0d | restore tf -
DUMP: can't find superblock
DUMP: The ENTIRE dump is aborted.
Checksum error 0, inode 0 file <name unknown>
Tape is not a dump tape
#
>Fix:
Index: sbin/dump/ffs_inode.c
===================================================================
RCS file: /cvsroot/src/sbin/dump/ffs_inode.c,v
retrieving revision 1.23
diff -u -r1.23 ffs_inode.c
--- sbin/dump/ffs_inode.c 1 Mar 2019 16:42:11 -0000 1.23
+++ sbin/dump/ffs_inode.c 15 Aug 2019 19:30:58 -0000
@@ -87,11 +87,13 @@
is_ufs2 = 1;
/*FALLTHROUGH*/
case FS_UFS1_MAGIC:
+ case HP_FS_MAGIC_LFN:
break;
case FS_UFS2_MAGIC_SWAPPED:
is_ufs2 = 1;
/*FALLTHROUGH*/
case FS_UFS1_MAGIC_SWAPPED:
+ case HP_FS_MAGIC_LFN_SWAPPED:
ns = 1;
ffs_sb_swap(sblock, sblock);
break;
@@ -130,6 +132,8 @@
*/
sblock->fs_qbmask = ~sblock->fs_bmask;
sblock->fs_qfmask = ~sblock->fs_fmask;
+ if (sblock->fs_magic == HP_FS_MAGIC_LFN)
+ sblock->fs_old_postblformat = FS_42POSTBLFMT;
}
#endif
Index: sbin/fsck_ffs/dir.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/dir.c,v
retrieving revision 1.61
diff -u -r1.61 dir.c
--- sbin/fsck_ffs/dir.c 5 May 2019 14:59:06 -0000 1.61
+++ sbin/fsck_ffs/dir.c 15 Aug 2019 19:30:58 -0000
@@ -741,7 +741,7 @@
if (expanddir(dp, pathbuf) == 0)
return (0);
update_uquot(idesc.id_number, idesc.id_uid, idesc.id_gid,
- btodb(sblock->fs_bsize), 0);
+ BTODB(sblock, sblock->fs_bsize), 0);
return (ckinode(dp, &idesc) & ALTERED);
}
@@ -778,14 +778,14 @@
dp2->di_db[lastbn] = iswap64(newblk);
dp2->di_size = iswap64(iswap64(dp2->di_size)+sblock->fs_bsize);
dp2->di_blocks = iswap64(iswap64(dp2->di_blocks) +
- btodb(sblock->fs_bsize));
+ BTODB(sblock, sblock->fs_bsize));
dirblk = iswap64(dp2->di_db[lastbn + 1]);
} else {
dp1->di_db[lastbn + 1] = dp1->di_db[lastbn];
dp1->di_db[lastbn] = iswap32((int32_t)newblk);
dp1->di_size = iswap64(iswap64(dp1->di_size)+sblock->fs_bsize);
dp1->di_blocks = iswap32(iswap32(dp1->di_blocks) +
- btodb(sblock->fs_bsize));
+ BTODB(sblock, sblock->fs_bsize));
dirblk = iswap32(dp1->di_db[lastbn + 1]);
}
bp = getdirblk(dirblk, ffs_sblksize(sblock, (daddr_t)DIP(dp, size), lastbn + 1));
@@ -820,13 +820,13 @@
dp2->di_db[lastbn + 1] = 0;
dp2->di_size = iswap64(iswap64(dp2->di_size)-sblock->fs_bsize);
dp2->di_blocks = iswap64(iswap64(dp2->di_blocks) -
- btodb(sblock->fs_bsize));
+ BTODB(sblock, sblock->fs_bsize));
} else {
dp1->di_db[lastbn] = dp1->di_db[lastbn + 1];
dp1->di_db[lastbn + 1] = 0;
dp1->di_size = iswap64(iswap64(dp1->di_size)-sblock->fs_bsize);
dp1->di_blocks = iswap32(iswap32(dp1->di_blocks) -
- btodb(sblock->fs_bsize));
+ BTODB(sblock, sblock->fs_bsize));
}
freeblk(newblk, sblock->fs_frag);
markclean = 0;
@@ -850,7 +850,7 @@
ino = allocino(request, IFDIR|mode);
if (ino < UFS_ROOTINO)
return 0;
- update_uquot(ino, 0, 0, btodb(sblock->fs_fsize), 1);
+ update_uquot(ino, 0, 0, BTODB(sblock, sblock->fs_fsize), 1);
dirhead.dot_reclen = iswap16(12);
dirhead.dotdot_reclen = iswap16(dirblksiz - 12);
odirhead.dot_reclen = iswap16(12);
Index: sbin/fsck_ffs/fsck.h
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/fsck.h,v
retrieving revision 1.53
diff -u -r1.53 fsck.h
--- sbin/fsck_ffs/fsck.h 5 May 2019 14:59:06 -0000 1.53
+++ sbin/fsck_ffs/fsck.h 15 Aug 2019 19:30:58 -0000
@@ -137,6 +137,14 @@
(bp)->b_un.b_indir1[i] = (val); \
} while (0)
+/*
+ * Turn byte counts into disk block counts.
+ * Performs the same function as btodb(), but without
+ * depending on a priori knowledge of DEV_BSIZE.
+ */
+#define BTODB(fs, size) ((size) >> ((fs)->fs_fshift - (fs)->fs_fsbtodb))
+#define DBTOB(fs, bc) ((bc) << ((fs)->fs_fshift - (fs)->fs_fsbtodb))
+
#define B_INUSE 1
#define MINBUFS 5 /* minimum number of buffers required */
Index: sbin/fsck_ffs/inode.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/inode.c,v
retrieving revision 1.72
diff -u -r1.72 inode.c
--- sbin/fsck_ffs/inode.c 8 Feb 2017 16:11:40 -0000 1.72
+++ sbin/fsck_ffs/inode.c 15 Aug 2019 19:30:58 -0000
@@ -797,7 +797,7 @@
dp2->di_atime = iswap64(t);
dp2->di_mtime = dp2->di_ctime = dp2->di_atime;
dp2->di_size = iswap64(ffs_lfragtosize(sblock, nfrags));
- dp2->di_blocks = iswap64(btodb(ffs_lfragtosize(sblock, nfrags)));
+ dp2->di_blocks = iswap64(BTODB(sblock, ffs_lfragtosize(sblock, nfrags)));
} else {
dp1 = &dp->dp1;
dp1->di_db[0] = iswap32(allocblk(nfrags));
@@ -811,7 +811,7 @@
dp1->di_atime = iswap32(t);
dp1->di_mtime = dp1->di_ctime = dp1->di_atime;
dp1->di_size = iswap64(ffs_lfragtosize(sblock, nfrags));
- dp1->di_blocks = iswap32(btodb(ffs_lfragtosize(sblock, nfrags)));
+ dp1->di_blocks = iswap32(BTODB(sblock, ffs_lfragtosize(sblock, nfrags)));
}
n_files++;
inodirty();
@@ -969,7 +969,7 @@
if ((bp = getnewblk(&newblk)) == NULL) {
return NULL;
}
- di_blocks += btodb(sblock->fs_bsize);
+ di_blocks += BTODB(sblock, sblock->fs_bsize);
if (is_ufs2) {
dp->dp2.di_db[blkno] = iswap64(newblk);
@@ -996,7 +996,7 @@
iswap32(dp->dp1.di_ib[ilevel - 1])) == 0) {
if ((ibp = getnewblk(&newblk)) == NULL)
return 0;
- di_blocks += btodb(sblock->fs_bsize);
+ di_blocks += BTODB(sblock, sblock->fs_bsize);
if (is_ufs2)
dp->dp2.di_ib[ilevel - 1] = iswap64(newblk);
else
@@ -1015,7 +1015,7 @@
if (iblkno == 0) {
if ((bp = getnewblk(&newblk)) == NULL)
return NULL;
- di_blocks += btodb(sblock->fs_bsize);
+ di_blocks += BTODB(sblock, sblock->fs_bsize);
if (is_ufs2)
ibp->b_un.b_indir2[blkno / nblks] =
iswap64(newblk);
Index: sbin/fsck_ffs/main.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/main.c,v
retrieving revision 1.85
diff -u -r1.85 main.c
--- sbin/fsck_ffs/main.c 5 May 2019 14:59:06 -0000 1.85
+++ sbin/fsck_ffs/main.c 15 Aug 2019 19:30:58 -0000
@@ -416,8 +416,14 @@
/*
* print out summary statistics
*/
- n_ffree = sblock->fs_cstotal.cs_nffree;
- n_bfree = sblock->fs_cstotal.cs_nbfree;
+ if (!is_ufs2 && ((sblock->fs_old_flags & FS_FLAGS_UPDATED) == 0) &&
+ sblock->fs_old_postblformat < FS_DYNAMICPOSTBLFMT) {
+ n_ffree = sblock->fs_old_cstotal.cs_nffree;
+ n_bfree = sblock->fs_old_cstotal.cs_nbfree;
+ } else {
+ n_ffree = sblock->fs_cstotal.cs_nffree;
+ n_bfree = sblock->fs_cstotal.cs_nbfree;
+ }
pwarn("%llu files, %lld used, %lld free ",
(unsigned long long)n_files, (long long)n_blks,
(long long)(n_ffree + sblock->fs_frag * n_bfree));
@@ -426,10 +432,15 @@
(long long)(n_ffree * 100 / (daddr_t)sblock->fs_dsize),
(long long)(((n_ffree * 1000 + (daddr_t)sblock->fs_dsize / 2)
/ (daddr_t)sblock->fs_dsize) % 10));
- if (debug &&
- (n_files -= maxino - UFS_ROOTINO - sblock->fs_cstotal.cs_nifree))
- printf("%llu files missing\n", (unsigned long long)n_files);
if (debug) {
+ long long int sbnifree;
+ if (!is_ufs2 && ((sblock->fs_old_flags & FS_FLAGS_UPDATED) == 0) &&
+ sblock->fs_old_postblformat < FS_DYNAMICPOSTBLFMT)
+ sbnifree = sblock->fs_old_cstotal.cs_nifree;
+ else
+ sbnifree = sblock->fs_cstotal.cs_nifree;
+ if (n_files -= maxino - UFS_ROOTINO - sbnifree)
+ printf("%llu files missing\n", (unsigned long long)n_files);
n_blks += sblock->fs_ncg *
(cgdmin(sblock, 0) - cgsblock(sblock, 0));
n_blks += cgsblock(sblock, 0) - cgbase(sblock, 0);
Index: sbin/fsck_ffs/pass1.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/pass1.c,v
retrieving revision 1.58
diff -u -r1.58 pass1.c
--- sbin/fsck_ffs/pass1.c 13 Feb 2018 11:20:08 -0000 1.58
+++ sbin/fsck_ffs/pass1.c 15 Aug 2019 19:30:58 -0000
@@ -444,7 +444,7 @@
}
}
#endif
- idesc->id_entryno *= btodb(sblock->fs_fsize);
+ idesc->id_entryno *= BTODB(sblock, sblock->fs_fsize);
if (is_ufs2)
blocks = iswap64(dp->dp2.di_blocks);
else
Index: sbin/fsck_ffs/pass4.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/pass4.c,v
retrieving revision 1.28
diff -u -r1.28 pass4.c
--- sbin/fsck_ffs/pass4.c 23 Jun 2013 22:03:34 -0000 1.28
+++ sbin/fsck_ffs/pass4.c 15 Aug 2019 19:30:58 -0000
@@ -195,7 +195,7 @@
if (idesc->id_type != SNAP) {
update_uquot(idesc->id_number,
idesc->id_uid, idesc->id_gid,
- -btodb(sblock->fs_fsize), 0);
+ -BTODB(sblock, sblock->fs_fsize), 0);
}
if (idesc->id_numfrags != sblock->fs_frag &&
cgp) {
Index: sbin/fsck_ffs/pass5.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/pass5.c,v
retrieving revision 1.54
diff -u -r1.54 pass5.c
--- sbin/fsck_ffs/pass5.c 23 Jun 2013 22:03:34 -0000 1.54
+++ sbin/fsck_ffs/pass5.c 15 Aug 2019 19:30:58 -0000
@@ -195,8 +195,8 @@
idesc[i].id_fix = FIX;
}
memset(&cstotal, 0, sizeof(struct csum_total));
- dmax = ffs_blknum(fs, fs->fs_size + fs->fs_frag - 1);
- for (d = fs->fs_size; d < dmax; d++)
+ dmax = ffs_blknum(fs, maxfsblock + fs->fs_frag - 1);
+ for (d = maxfsblock; d < dmax; d++)
setbmap(d);
for (c = 0; c < fs->fs_ncg; c++) {
if (got_siginfo) {
@@ -255,8 +255,8 @@
}
dbase = cgbase(fs, c);
dmax = dbase + fs->fs_fpg;
- if (dmax > fs->fs_size)
- dmax = fs->fs_size;
+ if (dmax > maxfsblock)
+ dmax = maxfsblock;
if (is_ufs2 || (fs->fs_old_flags & FS_FLAGS_UPDATED))
newcg->cg_time = cg->cg_time;
newcg->cg_old_time = cg->cg_old_time;
@@ -469,26 +469,59 @@
cgdirty();
}
}
- if (memcmp(&cstotal, &fs->fs_cstotal, cssize) != 0) {
- if (debug) {
- printf("total: nffree: %lld/%lld nbfree %lld/%lld"
- " nifree %lld/%lld ndir %lld/%lld\n",
- (long long int)fs->fs_cstotal.cs_nffree,
- (long long int)cstotal.cs_nffree,
- (long long int)fs->fs_cstotal.cs_nbfree,
- (long long int)cstotal.cs_nbfree,
- (long long int)fs->fs_cstotal.cs_nifree,
- (long long int)cstotal.cs_nifree,
- (long long int)fs->fs_cstotal.cs_ndir,
- (long long int)cstotal.cs_ndir);
- }
- if (dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
- memmove(&fs->fs_cstotal, &cstotal, sizeof cstotal);
- fs->fs_ronly = 0;
- fs->fs_fmod = 0;
- sbdirty();
- } else
- markclean = 0;
+ if (!is_ufs2 && ((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) &&
+ fs->fs_old_postblformat == FS_42POSTBLFMT) {
+ /* Test using old_cstotal */
+ struct csum old_cstotal;
+ memset(&old_cstotal, 0, sizeof(old_cstotal));
+ old_cstotal.cs_nffree = cstotal.cs_nffree;
+ old_cstotal.cs_nbfree = cstotal.cs_nbfree;
+ old_cstotal.cs_nifree = cstotal.cs_nifree;
+ old_cstotal.cs_ndir = cstotal.cs_ndir;
+ if (memcmp(&cstotal, &old_cstotal, sizeof(old_cstotal)) != 0) {
+ if (debug) {
+ printf("total: nffree: %lld/%lld nbfree %lld/%lld"
+ " nifree %lld/%lld ndir %lld/%lld\n",
+ (long long int)fs->fs_old_cstotal.cs_nffree,
+ (long long int)old_cstotal.cs_nffree,
+ (long long int)fs->fs_old_cstotal.cs_nbfree,
+ (long long int)old_cstotal.cs_nbfree,
+ (long long int)fs->fs_old_cstotal.cs_nifree,
+ (long long int)old_cstotal.cs_nifree,
+ (long long int)fs->fs_old_cstotal.cs_ndir,
+ (long long int)old_cstotal.cs_ndir);
+ }
+ if (dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
+ memmove(&fs->fs_old_cstotal, &old_cstotal, sizeof old_cstotal);
+ fs->fs_ronly = 0;
+ fs->fs_fmod = 0;
+ sbdirty();
+ } else
+ markclean = 0;
+ }
+ } else {
+ /* Test using new cstotal */
+ if (memcmp(&cstotal, &fs->fs_cstotal, cssize) != 0) {
+ if (debug) {
+ printf("total: nffree: %lld/%lld nbfree %lld/%lld"
+ " nifree %lld/%lld ndir %lld/%lld\n",
+ (long long int)fs->fs_cstotal.cs_nffree,
+ (long long int)cstotal.cs_nffree,
+ (long long int)fs->fs_cstotal.cs_nbfree,
+ (long long int)cstotal.cs_nbfree,
+ (long long int)fs->fs_cstotal.cs_nifree,
+ (long long int)cstotal.cs_nifree,
+ (long long int)fs->fs_cstotal.cs_ndir,
+ (long long int)cstotal.cs_ndir);
+ }
+ if (dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
+ memmove(&fs->fs_cstotal, &cstotal, sizeof cstotal);
+ fs->fs_ronly = 0;
+ fs->fs_fmod = 0;
+ sbdirty();
+ } else
+ markclean = 0;
+ }
}
#ifdef PROGRESS
if (!preen)
Index: sbin/fsck_ffs/setup.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_ffs/setup.c,v
retrieving revision 1.102
diff -u -r1.102 setup.c
--- sbin/fsck_ffs/setup.c 5 Oct 2018 09:49:23 -0000 1.102
+++ sbin/fsck_ffs/setup.c 15 Aug 2019 19:30:58 -0000
@@ -56,6 +56,7 @@
#include <err.h>
#include <errno.h>
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -150,6 +151,7 @@
dev_bsize = secsize = geo.dg_secsize;
else
dev_bsize = secsize = DEV_BSIZE;
+
/*
* Read in the superblock, looking for alternates if necessary
*/
@@ -227,7 +229,12 @@
if (!preen && !doswap)
pwarn("** File system is already clean\n");
}
- maxfsblock = sblock->fs_size;
+ if (sblock->fs_magic == HP_FS_MAGIC_LFN) {
+ maxfsblock = sblock->fs_old_size;
+ sblock->fs_old_postblformat = FS_42POSTBLFMT;
+ sblock->fs_dsize = sblock->fs_old_dsize;
+ } else
+ maxfsblock = sblock->fs_size;
maxino = sblock->fs_ncg * sblock->fs_ipg;
sizepb = sblock->fs_bsize;
maxfilesize = sblock->fs_bsize * UFS_NDADDR - 1;
@@ -465,11 +472,14 @@
goto badsblabel;
}
for (i = 0, j = 0; i < sblock->fs_cssize; i += sblock->fs_bsize, j++) {
+ int baseaddr = sblock->fs_csaddr;
+ if (!is_ufs2 && sblock->fs_old_postblformat == FS_42POSTBLFMT)
+ baseaddr = sblock->fs_old_csaddr;
size = sblock->fs_cssize - i < sblock->fs_bsize ?
sblock->fs_cssize - i : sblock->fs_bsize;
ccsp = (struct csum *)((char *)sblock->fs_csp + i);
if (bread(fsreadfd, (char *)ccsp,
- FFS_FSBTODB(sblock, sblock->fs_csaddr + j * sblock->fs_frag),
+ FFS_FSBTODB(sblock, baseaddr + j * sblock->fs_frag),
size) != 0 && !asked) {
pfatal("BAD SUMMARY INFORMATION");
if (reply("CONTINUE") == 0) {
@@ -551,6 +561,8 @@
dirblksiz = APPLEUFS_DIRBLKSIZ;
else
dirblksiz = UFS_DIRBLKSIZ;
+ if (dirblksiz < sblock->fs_fsize)
+ dirblksiz = sblock->fs_fsize;
if (debug)
#ifndef NO_APPLE_UFS
@@ -715,7 +727,8 @@
fs->fs_magic == FS_UFS1_MAGIC_SWAPPED))
/* Likely to be the first alternate of a fs with 64k blocks */
return -1;
- if (fs->fs_magic == FS_UFS1_MAGIC || fs->fs_magic == FS_UFS2_MAGIC) {
+ if (fs->fs_magic == FS_UFS1_MAGIC || fs->fs_magic == FS_UFS2_MAGIC ||
+ fs->fs_magic == HP_FS_MAGIC_LFN) {
#ifndef NO_FFS_EI
if (endian == 0 || BYTE_ORDER == endian) {
needswap = 0;
@@ -729,7 +742,8 @@
}
#ifndef NO_FFS_EI
else if (fs->fs_magic == FS_UFS1_MAGIC_SWAPPED ||
- fs->fs_magic == FS_UFS2_MAGIC_SWAPPED) {
+ fs->fs_magic == FS_UFS2_MAGIC_SWAPPED ||
+ fs->fs_magic == HP_FS_MAGIC_LFN_SWAPPED) {
if (endian == 0 || BYTE_ORDER != endian) {
needswap = 1;
doswap = do_blkswap = do_dirswap = 0;
@@ -827,6 +841,7 @@
sblk.b_size = SBLOCKSIZE;
if (bflag)
goto out;
+
/*
* Set all possible fields that could differ, then do check
* of whole super block against an alternate super block->
@@ -947,7 +962,7 @@
memmove(asb->fs_fsmnt, sb->fs_fsmnt, sizeof sb->fs_fsmnt);
memmove(asb->fs_volname, sb->fs_volname, sizeof sb->fs_volname);
- return memcmp(sb, asb, sb->fs_sbsize);
+ return memcmp(sb, asb, offsetof(struct fs, fs_dsize));
}
/* BSD 4.4 performed the following superblock comparison
Index: usr.sbin/dumpfs/dumpfs.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/dumpfs/dumpfs.c,v
retrieving revision 1.64
diff -u -r1.64 dumpfs.c
--- usr.sbin/dumpfs/dumpfs.c 6 Mar 2018 07:45:38 -0000 1.64
+++ usr.sbin/dumpfs/dumpfs.c 15 Aug 2019 19:30:58 -0000
@@ -196,12 +196,14 @@
is_ufs2 = 1;
break;
case FS_UFS1_MAGIC:
+ case HP_FS_MAGIC_LFN:
break;
case FS_UFS2_MAGIC_SWAPPED:
is_ufs2 = 1;
needswap = 1;
break;
case FS_UFS1_MAGIC_SWAPPED:
+ case HP_FS_MAGIC_LFN_SWAPPED:
needswap = 1;
break;
default:
@@ -250,6 +252,12 @@
static void
fix_superblock(struct fs *fs, uint16_t *opostbl)
{
+ if (needswap && fs->fs_magic == HP_FS_MAGIC_LFN_SWAPPED)
+ fs->fs_old_postblformat = (int32_t)bswap32(FS_42POSTBLFMT);
+
+ if (fs->fs_magic == HP_FS_MAGIC_LFN)
+ fs->fs_old_postblformat = FS_42POSTBLFMT;
+
if (needswap &&
(((int32_t)bswap32(fs->fs_old_postblformat) == FS_42POSTBLFMT) ||
(bswap32(fs->fs_old_postbloff) == offsetof(struct fs, fs_old_postbl_start)))) {
@@ -266,8 +274,9 @@
if (needswap)
ffs_sb_swap(fs, fs);
- printold = (fs->fs_magic == FS_UFS1_MAGIC &&
- (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0);
+ printold = ((fs->fs_magic == HP_FS_MAGIC_LFN ||
+ fs->fs_magic == FS_UFS1_MAGIC) &&
+ (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0);
if (printold) {
fs->fs_sblockloc = SBLOCK_UFS1;
fs->fs_flags = fs->fs_old_flags;
Index: sys/ufs/ffs/ffs_alloc.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_alloc.c,v
retrieving revision 1.164
diff -u -r1.164 ffs_alloc.c
--- sys/ufs/ffs/ffs_alloc.c 14 Apr 2019 15:55:24 -0000 1.164
+++ sys/ufs/ffs/ffs_alloc.c 15 Aug 2019 19:30:58 -0000
@@ -243,7 +243,7 @@
goto nospace;
#if defined(QUOTA) || defined(QUOTA2)
mutex_exit(&ump->um_lock);
- if ((error = chkdq(ip, btodb(size), cred, 0)) != 0)
+ if ((error = chkdq(ip, UFS_BTODB(ump, size), cred, 0)) != 0)
return (error);
mutex_enter(&ump->um_lock);
#endif
@@ -256,7 +256,7 @@
cg = dtog(fs, bpref);
bno = ffs_hashalloc(ip, cg, bpref, size, 0, flags, ffs_alloccg);
if (bno > 0) {
- DIP_ADD(ip, blocks, btodb(size));
+ DIP_ADD(ip, blocks, UFS_BTODB(ump, size));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
*bnp = bno;
return (0);
@@ -265,7 +265,7 @@
/*
* Restore user's disk quota because allocation failed.
*/
- (void) chkdq(ip, -btodb(size), cred, FORCE);
+ (void) chkdq(ip, -UFS_BTODB(ump, size), cred, FORCE);
#endif
if (flags & B_CONTIG) {
/*
@@ -389,7 +389,7 @@
return (error);
}
#if defined(QUOTA) || defined(QUOTA2)
- if ((error = chkdq(ip, btodb(nsize - osize), cred, 0)) != 0) {
+ if ((error = chkdq(ip, UFS_BTODB(ump, nsize - osize), cred, 0)) != 0) {
if (bpp != NULL) {
brelse(bp, 0);
}
@@ -402,7 +402,7 @@
cg = dtog(fs, bprev);
mutex_enter(&ump->um_lock);
if ((bno = ffs_fragextend(ip, cg, bprev, osize, nsize)) != 0) {
- DIP_ADD(ip, blocks, btodb(nsize - osize));
+ DIP_ADD(ip, blocks, UFS_BTODB(ump, nsize - osize));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
@@ -502,7 +502,7 @@
ffs_blkfree(fs, ip->i_devvp, bprev, (long)osize,
ip->i_number);
}
- DIP_ADD(ip, blocks, btodb(nsize - osize));
+ DIP_ADD(ip, blocks, UFS_BTODB(ump, nsize - osize));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
bp->b_blkno = FFS_FSBTODB(fs, bno);
@@ -525,7 +525,7 @@
/*
* Restore user's disk quota because allocation failed.
*/
- (void) chkdq(ip, -btodb(nsize - osize), cred, FORCE);
+ (void) chkdq(ip, -UFS_BTODB(ump, nsize - osize), cred, FORCE);
#endif
if (bpp != NULL) {
brelse(bp, 0);
@@ -992,7 +992,7 @@
if (!cg_chkmagic(cgp, UFS_FSNEEDSWAP(fs)))
goto fail;
cgp->cg_old_time = ufs_rw32(time_second, UFS_FSNEEDSWAP(fs));
- if ((fs->fs_magic != FS_UFS1_MAGIC) ||
+ if ((fs->fs_magic == FS_UFS2_MAGIC) ||
(fs->fs_old_flags & FS_FLAGS_UPDATED))
cgp->cg_time = ufs_rw64(time_second, UFS_FSNEEDSWAP(fs));
bno = dtogd(fs, bprev);
@@ -1068,7 +1068,7 @@
(cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize))
goto fail;
cgp->cg_old_time = ufs_rw32(time_second, needswap);
- if ((fs->fs_magic != FS_UFS1_MAGIC) ||
+ if ((fs->fs_magic == FS_UFS2_MAGIC) ||
(fs->fs_old_flags & FS_FLAGS_UPDATED))
cgp->cg_time = ufs_rw64(time_second, needswap);
if (size == fs->fs_bsize) {
@@ -1222,7 +1222,7 @@
ufs_add32(cgp->cg_cs.cs_nbfree, -1, needswap);
fs->fs_cstotal.cs_nbfree--;
fs->fs_cs(fs, ufs_rw32(cgp->cg_cgx, needswap)).cs_nbfree--;
- if ((fs->fs_magic == FS_UFS1_MAGIC) &&
+ if ((fs->fs_magic != FS_UFS2_MAGIC) &&
((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0)) {
int cylno;
cylno = old_cbtocylno(fs, bno);
@@ -1322,7 +1322,7 @@
}
cgp->cg_old_time = ufs_rw32(time_second, needswap);
- if ((fs->fs_magic != FS_UFS1_MAGIC) ||
+ if ((fs->fs_magic == FS_UFS2_MAGIC) ||
(fs->fs_old_flags & FS_FLAGS_UPDATED))
cgp->cg_time = ufs_rw64(time_second, needswap);
inosused = cg_inosused(cgp, needswap);
@@ -1868,7 +1868,7 @@
cg = dtog(fs, bno);
cgp = (struct cg *)bp->b_data;
cgp->cg_old_time = ufs_rw32(time_second, needswap);
- if ((fs->fs_magic != FS_UFS1_MAGIC) ||
+ if ((fs->fs_magic == FS_UFS2_MAGIC) ||
(fs->fs_old_flags & FS_FLAGS_UPDATED))
cgp->cg_time = ufs_rw64(time_second, needswap);
cgbno = dtogd(fs, bno);
@@ -1890,7 +1890,7 @@
ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap);
fs->fs_cstotal.cs_nbfree++;
fs->fs_cs(fs, cg).cs_nbfree++;
- if ((fs->fs_magic == FS_UFS1_MAGIC) &&
+ if ((fs->fs_magic != FS_UFS2_MAGIC) &&
((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0)) {
i = old_cbtocylno(fs, cgbno);
KASSERT(i >= 0);
@@ -1942,7 +1942,7 @@
ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap);
fs->fs_cstotal.cs_nbfree++;
fs->fs_cs(fs, cg).cs_nbfree++;
- if ((fs->fs_magic == FS_UFS1_MAGIC) &&
+ if ((fs->fs_magic != FS_UFS2_MAGIC) &&
((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0)) {
i = old_cbtocylno(fs, bbase);
KASSERT(i >= 0);
@@ -2065,7 +2065,7 @@
cg = ino_to_cg(fs, ino);
cgp = (struct cg *)bp->b_data;
cgp->cg_old_time = ufs_rw32(time_second, needswap);
- if ((fs->fs_magic != FS_UFS1_MAGIC) ||
+ if ((fs->fs_magic == FS_UFS2_MAGIC) ||
(fs->fs_old_flags & FS_FLAGS_UPDATED))
cgp->cg_time = ufs_rw64(time_second, needswap);
inosused = cg_inosused(cgp, needswap);
Index: sys/ufs/ffs/ffs_balloc.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_balloc.c,v
retrieving revision 1.63
diff -u -r1.63 ffs_balloc.c
--- sys/ufs/ffs/ffs_balloc.c 28 Oct 2017 00:37:13 -0000 1.63
+++ sys/ufs/ffs/ffs_balloc.c 15 Aug 2019 19:30:58 -0000
@@ -503,9 +503,9 @@
/*
* Restore user's disk quota because allocation failed.
*/
- (void)chkdq(ip, -btodb(deallocated), cred, FORCE);
+ (void)chkdq(ip, -UFS_BTODB(ump, deallocated), cred, FORCE);
#endif
- ip->i_ffs1_blocks -= btodb(deallocated);
+ DIP_ADD(ip, blocks, -UFS_BTODB(ump, deallocated));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
}
return (error);
@@ -1027,9 +1027,9 @@
/*
* Restore user's disk quota because allocation failed.
*/
- (void)chkdq(ip, -btodb(deallocated), cred, FORCE);
+ (void)chkdq(ip, -UFS_BTODB(ump, deallocated), cred, FORCE);
#endif
- ip->i_ffs2_blocks -= btodb(deallocated);
+ DIP_ADD(ip, blocks, -UFS_BTODB(ump, deallocated));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
}
Index: sys/ufs/ffs/ffs_inode.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_inode.c,v
retrieving revision 1.125
diff -u -r1.125 ffs_inode.c
--- sys/ufs/ffs/ffs_inode.c 10 Dec 2018 19:29:41 -0000 1.125
+++ sys/ufs/ffs/ffs_inode.c 15 Aug 2019 19:30:58 -0000
@@ -142,7 +142,7 @@
* Ensure that uid and gid are correct. This is a temporary
* fix until fsck has been changed to do the update.
*/
- if (fs->fs_magic == FS_UFS1_MAGIC && /* XXX */
+ if (fs->fs_magic != FS_UFS2_MAGIC && /* XXX */
fs->fs_old_inodefmt < FS_44INODEFMT) { /* XXX */
ip->i_ffs1_ouid = ip->i_uid; /* XXX */
ip->i_ffs1_ogid = ip->i_gid; /* XXX */
@@ -167,7 +167,7 @@
ip->i_number, ip->i_mode);
}
}
- if (fs->fs_magic == FS_UFS1_MAGIC) {
+ if (fs->fs_magic != FS_UFS2_MAGIC) {
cp = (char *)bp->b_data +
(ino_to_fsbo(fs, ip->i_number) * DINODE1_SIZE);
#ifdef FFS_EI
@@ -355,7 +355,7 @@
lastiblock[SINGLE] = lastblock - UFS_NDADDR;
lastiblock[DOUBLE] = lastiblock[SINGLE] - FFS_NINDIR(fs);
lastiblock[TRIPLE] = lastiblock[DOUBLE] - FFS_NINDIR(fs) * FFS_NINDIR(fs);
- nblocks = btodb(fs->fs_bsize);
+ nblocks = UFS_BTODB(ump, fs->fs_bsize);
/*
* Update file and block pointers on disk before we start freeing
* blocks. If we crash before free'ing blocks below, the blocks
@@ -479,7 +479,7 @@
} else
ffs_blkfree(fs, oip->i_devvp, bn, bsize, oip->i_number);
DIP_ASSIGN(oip, db[i], 0);
- blocksreleased += btodb(bsize);
+ blocksreleased += UFS_BTODB(ump, bsize);
}
if (lastblock < 0)
goto done;
@@ -522,7 +522,7 @@
} else
ffs_blkfree(fs, oip->i_devvp, bn,
oldspace - newspace, oip->i_number);
- blocksreleased += btodb(oldspace - newspace);
+ blocksreleased += UFS_BTODB(ump, oldspace - newspace);
}
}
@@ -618,7 +618,7 @@
last = lastbn;
if (lastbn > 0)
last /= factor;
- nblocks = btodb(fs->fs_bsize);
+ nblocks = UFS_BTODB((ip)->i_ump, fs->fs_bsize);
/*
* Get buffer of block pointers, zero those entries corresponding
* to blocks to be free'd, and update on disk copy first. Since
Index: sys/ufs/ffs/ffs_snapshot.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_snapshot.c,v
retrieving revision 1.149
diff -u -r1.149 ffs_snapshot.c
--- sys/ufs/ffs/ffs_snapshot.c 1 Jun 2017 02:45:15 -0000 1.149
+++ sys/ufs/ffs/ffs_snapshot.c 15 Aug 2019 19:30:58 -0000
@@ -1091,7 +1091,7 @@
* Set a snapshot inode to be a zero length file, regular files
* or unlinked snapshots to be completely unallocated.
*/
- if (fs->fs_magic == FS_UFS1_MAGIC) {
+ if (fs->fs_magic != FS_UFS2_MAGIC) {
dip1 = (struct ufs1_dinode *)bp->b_data +
ino_to_fsbo(fs, cancelip->i_number);
if (cancelip->i_flags & SF_SNAPSHOT) {
@@ -1125,14 +1125,14 @@
* using the function requested.
*/
numblks = howmany(cancelip->i_size, fs->fs_bsize);
- if (fs->fs_magic == FS_UFS1_MAGIC)
+ if (fs->fs_magic != FS_UFS2_MAGIC)
bap = &cancelip->i_ffs1_db[0];
else
bap = &cancelip->i_ffs2_db[0];
error = (*acctfunc)(snapvp, bap, 0, UFS_NDADDR, fs, 0, expungetype);
if (error)
return (error);
- if (fs->fs_magic == FS_UFS1_MAGIC)
+ if (fs->fs_magic != FS_UFS2_MAGIC)
bap = &cancelip->i_ffs1_ib[0];
else
bap = &cancelip->i_ffs2_ib[0];
@@ -1492,7 +1492,7 @@
else if ((dblk == ffs_blkstofrags(fs, blkno) &&
ffs_snapblkfree(fs, ip->i_devvp, dblk, fs->fs_bsize,
ip->i_number))) {
- DIP_ADD(ip, blocks, -btodb(fs->fs_bsize));
+ DIP_ADD(ip, blocks, -UFS_BTODB(ip->i_ump, fs->fs_bsize));
db_assign(ip, blkno, 0);
}
}
@@ -1513,7 +1513,7 @@
else if (dblk == ffs_blkstofrags(fs, blkno) &&
ffs_snapblkfree(fs, ip->i_devvp, dblk,
fs->fs_bsize, ip->i_number)) {
- DIP_ADD(ip, blocks, -btodb(fs->fs_bsize));
+ DIP_ADD(ip, blocks, -UFS_BTODB(ip->i_ump, fs->fs_bsize));
idb_assign(ip, ibp->b_data, loc, 0);
}
}
@@ -1667,7 +1667,7 @@
else
bdwrite(ibp);
}
- DIP_ADD(ip, blocks, btodb(size));
+ DIP_ADD(ip, blocks, UFS_BTODB(ip->i_ump, size));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (ip->i_nlink > 0 && mp->mnt_wapbl)
error = syncsnap(vp);
@@ -1928,7 +1928,7 @@
fs->fs_journallocs[UFS_WAPBL_INFS_BLKSZ];
log_end = log_start + fs->fs_journallocs[UFS_WAPBL_INFS_COUNT] *
fs->fs_journallocs[UFS_WAPBL_INFS_BLKSZ];
- blk_off = dbtob(bp->b_blkno);
+ blk_off = UFS_DBTOB(VFSTOUFS(mp), bp->b_blkno);
if (blk_off >= log_start && blk_off < log_end) {
mutex_exit(&si->si_lock);
return 0;
Index: sys/ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.362
diff -u -r1.362 ffs_vfsops.c
--- sys/ufs/ffs/ffs_vfsops.c 20 Jun 2019 03:31:30 -0000 1.362
+++ sys/ufs/ffs/ffs_vfsops.c 15 Aug 2019 19:30:58 -0000
@@ -789,6 +789,7 @@
brelse(bp, 0);
if ((newfs->fs_magic != FS_UFS1_MAGIC) &&
+ (newfs->fs_magic != HP_FS_MAGIC_LFN) &&
(newfs->fs_magic != FS_UFS2_MAGIC)) {
kmem_free(newfs, fs_sbsize);
return (EIO); /* XXX needs translation */
@@ -904,6 +905,10 @@
*lp++ = fs->fs_contigsumsize;
}
+ if (fs->fs_magic == HP_FS_MAGIC_LFN && ump->um_dirblksiz < fs->fs_fsize) {
+ ump->um_dirblksiz = fs->fs_fsize;
+ }
+
vfs_vnode_iterator_init(mp, &marker);
while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL))) {
/*
@@ -984,7 +989,7 @@
return 0;
/* Check the number of inodes per block */
- if (fs->fs_magic == FS_UFS1_MAGIC)
+ if (fs->fs_magic != FS_UFS2_MAGIC)
fs_inopb = fs->fs_bsize / sizeof(struct ufs1_dinode);
else /* fs->fs_magic == FS_UFS2_MAGIC */
fs_inopb = fs->fs_bsize / sizeof(struct ufs2_dinode);
@@ -1019,6 +1024,10 @@
if (fs->fs_fmask != ~(fs->fs_fsize - 1))
return 0;
+ /* Set fs_old_postblformat for HP/UX HFS filesystem */
+ if (fs->fs_magic == HP_FS_MAGIC_LFN)
+ fs->fs_old_postblformat = FS_42POSTBLFMT;
+
/*
* Now that the shifts and masks are sanitized, we can use the ffs_ API.
*/
@@ -1159,12 +1168,12 @@
* size to read the superblock. Once read, we swap the whole
* superblock structure.
*/
- if (fs->fs_magic == FS_UFS1_MAGIC) {
+ if (fs->fs_magic == FS_UFS1_MAGIC || fs->fs_magic == HP_FS_MAGIC_LFN) {
fs_sbsize = fs->fs_sbsize;
fstype = UFS1;
#ifdef FFS_EI
needswap = 0;
- } else if (fs->fs_magic == FS_UFS1_MAGIC_SWAPPED) {
+ } else if (fs->fs_magic == FS_UFS1_MAGIC_SWAPPED || fs->fs_magic == HP_FS_MAGIC_LFN_SWAPPED) {
fs_sbsize = bswap32(fs->fs_sbsize);
fstype = UFS1;
needswap = 1;
@@ -1233,6 +1242,7 @@
}
ump->um_fs = fs;
+ ump->um_dbshift = fs->fs_fshift - fs->fs_fsbtodb;
#ifdef WAPBL
if ((mp->mnt_wapbl_replay == 0) && (fs->fs_flags & FS_DOWAPBL)) {
@@ -1470,6 +1480,10 @@
spec_node_setmountedfs(devvp, mp);
if (ronly == 0 && fs->fs_snapinum[0] != 0)
ffs_snapshot_mount(mp);
+
+ if (fs->fs_magic == HP_FS_MAGIC_LFN)
+ ump->um_dirblksiz = UFS_DBTOB(ump, MAX(1, UFS_BTODB(ump, ump->um_dirblksiz)));
+
#ifdef WAPBL
if (!ronly) {
KDASSERT(fs->fs_ronly == 0);
@@ -1555,7 +1569,7 @@
off_t maxfilesize;
int32_t *extrasave;
- if ((fs->fs_magic != FS_UFS1_MAGIC) ||
+ if ((fs->fs_magic == FS_UFS2_MAGIC) ||
(fs->fs_old_flags & FS_FLAGS_UPDATED))
return;
@@ -1588,6 +1602,11 @@
fs->fs_flags = fs->fs_old_flags | (fs->fs_flags & FS_INTERNAL);
+ if (fs->fs_magic == HP_FS_MAGIC_LFN) {
+ fs->fs_flags &= FS_INTERNAL;
+ fs->fs_old_postblformat = FS_42POSTBLFMT;
+ }
+
if (fs->fs_old_postblformat == FS_42POSTBLFMT) {
fs->fs_old_nrpos = 8;
fs->fs_old_npsect = fs->fs_old_nsect;
@@ -1595,7 +1614,7 @@
fs->fs_old_trackskew = 0;
}
- if (fs->fs_magic == FS_UFS1_MAGIC &&
+ if (fs->fs_magic != FS_UFS2_MAGIC &&
fs->fs_old_inodefmt < FS_44INODEFMT) {
fs->fs_maxfilesize = (u_quad_t) 1LL << 39;
fs->fs_qbmask = ~fs->fs_bmask;
@@ -1632,7 +1651,7 @@
{
int32_t *extrasave;
- if ((fs->fs_magic != FS_UFS1_MAGIC) ||
+ if ((fs->fs_magic == FS_UFS2_MAGIC) ||
(fs->fs_old_flags & FS_FLAGS_UPDATED))
return;
@@ -1641,7 +1660,7 @@
fs->fs_old_cstotal.cs_nbfree = fs->fs_cstotal.cs_nbfree;
fs->fs_old_cstotal.cs_nifree = fs->fs_cstotal.cs_nifree;
fs->fs_old_cstotal.cs_nffree = fs->fs_cstotal.cs_nffree;
- fs->fs_old_flags = fs->fs_flags;
+ fs->fs_old_flags = fs->fs_flags & ~FS_INTERNAL;
#if 0
if (bigcgs) {
@@ -1656,6 +1675,11 @@
fs->fs_old_interleave = extrasave[1];
fs->fs_old_trackskew = extrasave[2];
+ if (fs->fs_magic == HP_FS_MAGIC_LFN) {
+ fs->fs_old_flags = 0x0;
+ if (fs->fs_clean & FS_ISCLEAN)
+ fs->fs_clean = HP_FS_CLEAN;
+ }
}
/*
@@ -2076,7 +2100,7 @@
* fix until fsck has been changed to do the update.
*/
- if (fs->fs_magic == FS_UFS1_MAGIC && /* XXX */
+ if (fs->fs_magic != FS_UFS2_MAGIC && /* XXX */
fs->fs_old_inodefmt < FS_44INODEFMT) { /* XXX */
ip->i_uid = ip->i_ffs1_ouid; /* XXX */
ip->i_gid = ip->i_ffs1_ogid; /* XXX */
Index: sys/ufs/ffs/ffs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vnops.c,v
retrieving revision 1.129
diff -u -r1.129 ffs_vnops.c
--- sys/ufs/ffs/ffs_vnops.c 26 May 2017 14:21:02 -0000 1.129
+++ sys/ufs/ffs/ffs_vnops.c 15 Aug 2019 19:30:58 -0000
@@ -625,7 +625,7 @@
struct fs *fs = ip->i_fs;
/* Not supported for UFS1 file systems. */
- if (fs->fs_magic == FS_UFS1_MAGIC)
+ if (fs->fs_magic != FS_UFS2_MAGIC)
return (EOPNOTSUPP);
/* XXX Not implemented for UFS2 file systems. */
@@ -645,7 +645,7 @@
struct fs *fs = ip->i_fs;
/* Not supported for UFS1 file systems. */
- if (fs->fs_magic == FS_UFS1_MAGIC)
+ if (fs->fs_magic != FS_UFS2_MAGIC)
return (EOPNOTSUPP);
/* XXX Not implemented for UFS2 file systems. */
@@ -668,7 +668,7 @@
struct inode *ip = VTOI(vp);
struct fs *fs = ip->i_fs;
- if (fs->fs_magic == FS_UFS1_MAGIC) {
+ if (fs->fs_magic != FS_UFS2_MAGIC) {
#ifdef UFS_EXTATTR
int error;
@@ -698,7 +698,7 @@
struct inode *ip = VTOI(vp);
struct fs *fs = ip->i_fs;
- if (fs->fs_magic == FS_UFS1_MAGIC) {
+ if (fs->fs_magic != FS_UFS2_MAGIC) {
#ifdef UFS_EXTATTR
int error;
@@ -727,7 +727,7 @@
struct inode *ip = VTOI(ap->a_vp);
struct fs *fs = ip->i_fs;
- if (fs->fs_magic == FS_UFS1_MAGIC) {
+ if (fs->fs_magic != FS_UFS2_MAGIC) {
#ifdef UFS_EXTATTR
int error;
@@ -755,7 +755,7 @@
struct inode *ip = VTOI(vp);
struct fs *fs = ip->i_fs;
- if (fs->fs_magic == FS_UFS1_MAGIC) {
+ if (fs->fs_magic != FS_UFS2_MAGIC) {
#ifdef UFS_EXTATTR
int error;
Index: sys/ufs/ffs/ffs_wapbl.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_wapbl.c,v
retrieving revision 1.44
diff -u -r1.44 ffs_wapbl.c
--- sys/ufs/ffs/ffs_wapbl.c 1 Jan 2019 10:06:55 -0000 1.44
+++ sys/ufs/ffs/ffs_wapbl.c 15 Aug 2019 19:30:58 -0000
@@ -97,7 +97,7 @@
static int
ffs_superblock_layout(struct fs *fs)
{
- if ((fs->fs_magic == FS_UFS1_MAGIC) &&
+ if ((fs->fs_magic != FS_UFS2_MAGIC) &&
((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0))
return 1;
else
@@ -586,9 +586,9 @@
if (error)
return error;
KDASSERT(secsize != 0);
- logend = btodb(numsecs * secsize);
+ logend = UFS_BTODB(ump, numsecs * secsize);
- if (dbtob(logend - logstart) >= desired_logsize) {
+ if (UFS_DBTOB(ump, logend - logstart) >= desired_logsize) {
DPRINTF("enough space, use end-of-partition log\n");
location = UFS_WAPBL_JOURNALLOC_END_PARTITION;
@@ -599,8 +599,8 @@
*extradatap = 0;
/* convert to physical block numbers */
- *startp = dbtob(*startp) / secsize;
- *countp = dbtob(*countp) / secsize;
+ *startp = UFS_DBTOB(ump, *startp) / secsize;
+ *countp = UFS_DBTOB(ump, *countp) / secsize;
fs->fs_journallocs[UFS_WAPBL_EPART_ADDR] = *startp;
fs->fs_journallocs[UFS_WAPBL_EPART_COUNT] = *countp;
@@ -618,8 +618,8 @@
ffs_sync(mp, MNT_WAIT, FSCRED);
/* convert to physical block numbers */
- *startp = dbtob(*startp) / secsize;
- *countp = dbtob(*countp) / secsize;
+ *startp = UFS_DBTOB(ump, *startp) / secsize;
+ *countp = UFS_DBTOB(ump, *countp) / secsize;
fs->fs_journallocs[UFS_WAPBL_INFS_ADDR] = *startp;
fs->fs_journallocs[UFS_WAPBL_INFS_COUNT] = *countp;
@@ -743,7 +743,7 @@
}
*startp = FFS_FSBTODB(fs, addr);
- *countp = btodb(logsize);
+ *countp = UFS_BTODB(ump, logsize);
*extradatap = VTOI(vp)->i_number;
return 0;
Index: sys/ufs/ffs/fs.h
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/fs.h,v
retrieving revision 1.66
diff -u -r1.66 fs.h
--- sys/ufs/ffs/fs.h 14 Feb 2015 09:06:11 -0000 1.66
+++ sys/ufs/ffs/fs.h 15 Aug 2019 19:30:58 -0000
@@ -400,6 +400,8 @@
#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast file system magic number */
#define FS_UFS1_MAGIC_SWAPPED 0x54190100
#define FS_UFS2_MAGIC_SWAPPED 0x19015419
+#define HP_FS_MAGIC_LFN 0x095014 /* HP/UX UFS1 variant */
+#define HP_FS_MAGIC_LFN_SWAPPED 0x14500900
#define FS_OKAY 0x7c269d38 /* superblock checksum */
#define FS_42INODEFMT -1 /* 4.2BSD inode format */
#define FS_44INODEFMT 2 /* 4.4BSD inode format */
@@ -409,6 +411,7 @@
*/
#define FS_ISCLEAN 0x01
#define FS_WASCLEAN 0x02
+#define HP_FS_CLEAN 0x17
/*
* Preference for optimization.
Index: sys/ufs/ufs/ufs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.247
diff -u -r1.247 ufs_vnops.c
--- sys/ufs/ufs/ufs_vnops.c 1 Jul 2019 00:57:06 -0000 1.247
+++ sys/ufs/ufs/ufs_vnops.c 15 Aug 2019 19:30:58 -0000
@@ -385,7 +385,7 @@
vap->va_ctime.tv_nsec = ip->i_ffs1_ctimensec;
vap->va_birthtime.tv_sec = 0;
vap->va_birthtime.tv_nsec = 0;
- vap->va_bytes = dbtob((u_quad_t)ip->i_ffs1_blocks);
+ vap->va_bytes = UFS_DBTOB(ip->i_ump, (u_quad_t)ip->i_ffs1_blocks);
} else {
switch (vp->v_type) {
case VBLK:
@@ -405,7 +405,7 @@
vap->va_ctime.tv_nsec = ip->i_ffs2_ctimensec;
vap->va_birthtime.tv_sec = ip->i_ffs2_birthtime;
vap->va_birthtime.tv_nsec = ip->i_ffs2_birthnsec;
- vap->va_bytes = dbtob(ip->i_ffs2_blocks);
+ vap->va_bytes = UFS_DBTOB(ip->i_ump, ip->i_ffs2_blocks);
}
vap->va_gen = ip->i_gen;
vap->va_flags = ip->i_flags;
Index: sys/ufs/ufs/ufsmount.h
===================================================================
RCS file: /cvsroot/src/sys/ufs/ufs/ufsmount.h,v
retrieving revision 1.43
diff -u -r1.43 ufsmount.h
--- sys/ufs/ufs/ufsmount.h 27 Mar 2015 17:27:56 -0000 1.43
+++ sys/ufs/ufs/ufsmount.h 15 Aug 2019 19:30:58 -0000
@@ -122,6 +122,7 @@
int um_dirblksiz;
u_int64_t um_maxfilesize;
void *um_snapinfo; /* snapshot private data */
+ int um_dbshift; /* for UFS_BTODB */
const struct ufs_ops *um_ops;
@@ -192,6 +193,8 @@
*/
#define MNINDIR(ump) ((ump)->um_nindir)
#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb)
+#define UFS_BTODB(ump, size) ((size) >> (ump)->um_dbshift)
+#define UFS_DBTOB(ump, bc) ((bc) << (ump)->um_dbshift)
/*
* Predicate for byte-swapping support.
Home |
Main Index |
Thread Index |
Old Index