add uuid field to apple ufs volume label

This commit is contained in:
dbj 2004-01-02 05:08:57 +00:00
parent 7569ff6812
commit 23d4eb34b2
5 changed files with 43 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: setup.c,v 1.63 2003/10/20 12:04:38 dsl Exp $ */
/* $NetBSD: setup.c,v 1.64 2004/01/02 05:08:57 dbj Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
#else
__RCSID("$NetBSD: setup.c,v 1.63 2003/10/20 12:04:38 dsl Exp $");
__RCSID("$NetBSD: setup.c,v 1.64 2004/01/02 05:08:57 dbj Exp $");
#endif
#endif /* not lint */
@ -479,7 +479,7 @@ readappleufs()
if (reply("FIX") == 0) {
return 1;
}
ffs_appleufs_set(appleufs,NULL,-1);
ffs_appleufs_set(appleufs, NULL, -1, 0);
appleufsdirty();
}
}
@ -513,7 +513,7 @@ readappleufs()
printf(" (FIXED)\n");
}
if (preen || reply("FIX")) {
ffs_appleufs_set(appleufs,NULL,-1);
ffs_appleufs_set(appleufs, NULL, -1, 0);
appleufsdirty();
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkfs.c,v 1.84 2003/10/29 08:14:13 lukem Exp $ */
/* $NetBSD: mkfs.c,v 1.85 2004/01/02 05:08:57 dbj Exp $ */
/*
* Copyright (c) 1980, 1989, 1993
@ -73,7 +73,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
#else
__RCSID("$NetBSD: mkfs.c,v 1.84 2003/10/29 08:14:13 lukem Exp $");
__RCSID("$NetBSD: mkfs.c,v 1.85 2004/01/02 05:08:57 dbj Exp $");
#endif
#endif /* not lint */
@ -588,9 +588,19 @@ mkfs(struct partition *pp, const char *fsys, int fi, int fo,
if (isappleufs) {
struct appleufslabel appleufs;
ffs_appleufs_set(&appleufs, appleufs_volname, tv.tv_sec);
ffs_appleufs_set(&appleufs, appleufs_volname, tv.tv_sec, 0);
wtfs(APPLEUFS_LABEL_OFFSET/sectorsize, APPLEUFS_LABEL_SIZE,
&appleufs);
} else {
struct appleufslabel appleufs;
/* Look for and zap any existing valid apple ufs labels */
rdfs(APPLEUFS_LABEL_OFFSET/sectorsize, APPLEUFS_LABEL_SIZE,
&appleufs);
if (ffs_appleufs_validate(fsys, &appleufs, NULL) == 0) {
memset(&appleufs, 0, sizeof(appleufs));
wtfs(APPLEUFS_LABEL_OFFSET/sectorsize, APPLEUFS_LABEL_SIZE,
&appleufs);
}
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_appleufs.c,v 1.3 2003/10/13 17:07:55 thorpej Exp $ */
/* $NetBSD: ffs_appleufs.c,v 1.4 2004/01/02 05:08:57 dbj Exp $ */
/*
* Copyright (c) 2002 Darrin B. Jewell
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_appleufs.c,v 1.3 2003/10/13 17:07:55 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_appleufs.c,v 1.4 2004/01/02 05:08:57 dbj Exp $");
#include <sys/param.h>
#include <sys/time.h>
@ -115,21 +115,26 @@ ffs_appleufs_validate(name,o,n)
#endif
n->ul_namelen = APPLEUFS_MAX_LABEL_NAME;
}
/* if len is max, will set ul_reserved[0] */
n->ul_name[n->ul_namelen] = '\0';
#ifdef DEBUG
printf("%s: found APPLE UFS label v%d: \"%s\"\n",
name,n->ul_version,n->ul_name);
{
unsigned char foundname[APPLEUFS_MAX_LABEL_NAME+1];
memcpy(foundname,n->ul_name,n->ul_namelen);
foundname[n->ul_namelen] = '\0';
printf("%s: found APPLE UFS label v%d: \"%s\"\n",
name,n->ul_version,foundname);
}
#endif
n->ul_uuid = be64toh(o->ul_uuid);
return 0;
}
void
ffs_appleufs_set(appleufs,name,t)
ffs_appleufs_set(appleufs, name, t, uuid)
struct appleufslabel *appleufs;
const char *name;
time_t t;
uint64_t uuid;
{
size_t namelen;
if (!name) name = "untitled";
@ -140,6 +145,13 @@ ffs_appleufs_set(appleufs,name,t)
t = 0;
#else
(void)time(&t);
#endif
}
if (uuid == 0) {
#if defined(_KERNEL) && !defined(STANDALONE)
uuid = arc4random();
uuid <<= 32;
uuid |= arc4random();
#endif
}
namelen = strlen(name);
@ -151,5 +163,6 @@ ffs_appleufs_set(appleufs,name,t)
appleufs->ul_time = htobe32((u_int32_t)t);
appleufs->ul_namelen = htobe16(namelen);
strncpy(appleufs->ul_name,name,namelen);
appleufs->ul_uuid = htobe64(uuid);
appleufs->ul_checksum = ffs_appleufs_cksum(appleufs);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_extern.h,v 1.34 2003/12/04 19:38:25 atatat Exp $ */
/* $NetBSD: ffs_extern.h,v 1.35 2004/01/02 05:08:57 dbj Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -140,7 +140,7 @@ int ffs_cgupdate __P((struct ufsmount *, int));
/* ffs_appleufs.c */
u_int16_t ffs_appleufs_cksum __P((const struct appleufslabel *));
int ffs_appleufs_validate __P((const char*,const struct appleufslabel *,struct appleufslabel *));
void ffs_appleufs_set __P((struct appleufslabel *, const char *, time_t));
void ffs_appleufs_set __P((struct appleufslabel *, const char *, time_t, uint64_t));
/* ffs_vnops.c */

View File

@ -1,4 +1,4 @@
/* $NetBSD: fs.h,v 1.37 2003/12/31 19:19:39 dbj Exp $ */
/* $NetBSD: fs.h,v 1.38 2004/01/02 05:08:57 dbj Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@ -616,8 +616,9 @@ struct appleufslabel {
u_int32_t ul_version;
u_int32_t ul_time;
u_int16_t ul_namelen;
u_char ul_name[APPLEUFS_MAX_LABEL_NAME];
u_char ul_reserved[32];
u_char ul_name[APPLEUFS_MAX_LABEL_NAME]; /* Warning: may not be null terminated */
u_int64_t ul_uuid;
u_char ul_reserved[24];
u_char ul_unused[460];
};