add uuid field to apple ufs volume label
This commit is contained in:
parent
7569ff6812
commit
23d4eb34b2
|
@ -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
|
* Copyright (c) 1980, 1986, 1993
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
|
static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
|
||||||
#else
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ readappleufs()
|
||||||
if (reply("FIX") == 0) {
|
if (reply("FIX") == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ffs_appleufs_set(appleufs,NULL,-1);
|
ffs_appleufs_set(appleufs, NULL, -1, 0);
|
||||||
appleufsdirty();
|
appleufsdirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ readappleufs()
|
||||||
printf(" (FIXED)\n");
|
printf(" (FIXED)\n");
|
||||||
}
|
}
|
||||||
if (preen || reply("FIX")) {
|
if (preen || reply("FIX")) {
|
||||||
ffs_appleufs_set(appleufs,NULL,-1);
|
ffs_appleufs_set(appleufs, NULL, -1, 0);
|
||||||
appleufsdirty();
|
appleufsdirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1980, 1989, 1993
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
|
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
|
||||||
#else
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -588,9 +588,19 @@ mkfs(struct partition *pp, const char *fsys, int fi, int fo,
|
||||||
|
|
||||||
if (isappleufs) {
|
if (isappleufs) {
|
||||||
struct appleufslabel appleufs;
|
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,
|
wtfs(APPLEUFS_LABEL_OFFSET/sectorsize, APPLEUFS_LABEL_SIZE,
|
||||||
&appleufs);
|
&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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -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
|
* Copyright (c) 2002 Darrin B. Jewell
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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/param.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -115,21 +115,26 @@ ffs_appleufs_validate(name,o,n)
|
||||||
#endif
|
#endif
|
||||||
n->ul_namelen = APPLEUFS_MAX_LABEL_NAME;
|
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
|
#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
|
#endif
|
||||||
|
n->ul_uuid = be64toh(o->ul_uuid);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ffs_appleufs_set(appleufs,name,t)
|
ffs_appleufs_set(appleufs, name, t, uuid)
|
||||||
struct appleufslabel *appleufs;
|
struct appleufslabel *appleufs;
|
||||||
const char *name;
|
const char *name;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
uint64_t uuid;
|
||||||
{
|
{
|
||||||
size_t namelen;
|
size_t namelen;
|
||||||
if (!name) name = "untitled";
|
if (!name) name = "untitled";
|
||||||
|
@ -140,6 +145,13 @@ ffs_appleufs_set(appleufs,name,t)
|
||||||
t = 0;
|
t = 0;
|
||||||
#else
|
#else
|
||||||
(void)time(&t);
|
(void)time(&t);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (uuid == 0) {
|
||||||
|
#if defined(_KERNEL) && !defined(STANDALONE)
|
||||||
|
uuid = arc4random();
|
||||||
|
uuid <<= 32;
|
||||||
|
uuid |= arc4random();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
namelen = strlen(name);
|
namelen = strlen(name);
|
||||||
|
@ -151,5 +163,6 @@ ffs_appleufs_set(appleufs,name,t)
|
||||||
appleufs->ul_time = htobe32((u_int32_t)t);
|
appleufs->ul_time = htobe32((u_int32_t)t);
|
||||||
appleufs->ul_namelen = htobe16(namelen);
|
appleufs->ul_namelen = htobe16(namelen);
|
||||||
strncpy(appleufs->ul_name,name,namelen);
|
strncpy(appleufs->ul_name,name,namelen);
|
||||||
|
appleufs->ul_uuid = htobe64(uuid);
|
||||||
appleufs->ul_checksum = ffs_appleufs_cksum(appleufs);
|
appleufs->ul_checksum = ffs_appleufs_cksum(appleufs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1991, 1993, 1994
|
||||||
|
@ -140,7 +140,7 @@ int ffs_cgupdate __P((struct ufsmount *, int));
|
||||||
/* ffs_appleufs.c */
|
/* ffs_appleufs.c */
|
||||||
u_int16_t ffs_appleufs_cksum __P((const struct appleufslabel *));
|
u_int16_t ffs_appleufs_cksum __P((const struct appleufslabel *));
|
||||||
int ffs_appleufs_validate __P((const char*,const struct appleufslabel *,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 */
|
/* ffs_vnops.c */
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1982, 1986, 1993
|
||||||
|
@ -616,8 +616,9 @@ struct appleufslabel {
|
||||||
u_int32_t ul_version;
|
u_int32_t ul_version;
|
||||||
u_int32_t ul_time;
|
u_int32_t ul_time;
|
||||||
u_int16_t ul_namelen;
|
u_int16_t ul_namelen;
|
||||||
u_char ul_name[APPLEUFS_MAX_LABEL_NAME];
|
u_char ul_name[APPLEUFS_MAX_LABEL_NAME]; /* Warning: may not be null terminated */
|
||||||
u_char ul_reserved[32];
|
u_int64_t ul_uuid;
|
||||||
|
u_char ul_reserved[24];
|
||||||
u_char ul_unused[460];
|
u_char ul_unused[460];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue