1
Index: ufsutils/mkfs.ufs/mkfs.c
2
===================================================================
3
--- ufsutils.orig/mkfs.ufs/mkfs.c
4
+++ ufsutils/mkfs.ufs/mkfs.c
2
sbin/newfs/Makefile | 22 ++++++++++------------
3
sbin/newfs/mkfs.c | 1 +
4
sbin/newfs/newfs.8 | 4 ++--
5
sbin/newfs/newfs.c | 22 ++++++++++++++++++----
6
4 files changed, 31 insertions(+), 18 deletions(-)
8
--- a/sbin/newfs/mkfs.c
9
+++ b/sbin/newfs/mkfs.c
10
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
10
15
#include <sys/param.h>
11
16
#include <sys/time.h>
12
17
#include <sys/types.h>
13
Index: ufsutils/mkfs.ufs/newfs.c
14
===================================================================
15
--- ufsutils.orig/mkfs.ufs/newfs.c
16
+++ ufsutils/mkfs.ufs/newfs.c
18
--- a/sbin/newfs/newfs.c
19
+++ b/sbin/newfs/newfs.c
20
@@ -55,7 +55,9 @@ __FBSDID("$FreeBSD$");
19
22
#include <sys/param.h>
20
23
#include <sys/stat.h>
21
-#include <sys/disk.h>
24
+#ifdef HAVE_BSD_DISKLABEL
22
27
#include <sys/disklabel.h>
23
28
#include <sys/file.h>
24
29
#include <sys/mount.h>
26
static char device[MAXPATHLEN];
27
static char *disktype;
29
+static char *progname;
31
static struct disklabel *getdisklabel(char *s);
32
static void rewritelabel(char *s, struct disklabel *lp);
30
@@ -133,6 +135,8 @@ main(int argc, char *argv[])
32
char part_name; /* partition name, default to full disk */
34
+ setprogname(argv[0]);
39
38
while ((ch = getopt(argc, argv,
40
"EJL:NO:RS:T:Ua:b:c:d:e:f:g:h:i:lm:no:s:")) != -1)
39
@@ -303,8 +307,9 @@ main(int argc, char *argv[])
44
41
if (fstat(disk.d_fd, &st) < 0)
45
42
err(1, "%s", special);
47
if ((st.st_mode & S_IFMT) != S_IFCHR)
48
errx(1, "%s: not a character-special device", special);
43
- if ((st.st_mode & S_IFMT) != S_IFCHR) {
44
- warn("%s: not a character-special device", special);
45
+ if ((st.st_mode & S_IFMT) != S_IFCHR &&
46
+ (st.st_mode & S_IFMT) != S_IFBLK) {
47
+ warn("%s: not a block or character-special device", special);
48
is_file = 1; /* assume it is a file */
51
@@ -312,10 +317,15 @@ main(int argc, char *argv[])
52
mediasize = st.st_size;
53
/* set fssize from the partition */
51
55
+#ifdef HAVE_BSD_DISKLABEL
53
ioctl(disk.d_fd, DIOCGSECTORSIZE, §orsize);
54
- if (sectorsize && !ioctl(disk.d_fd, DIOCGMEDIASIZE, &mediasize)) {
57
if (ioctl(disk.d_fd, DIOCGSECTORSIZE, §orsize) == -1)
58
sectorsize = 0; /* back out on error for safety */
59
- if (sectorsize && ioctl(disk.d_fd, DIOCGMEDIASIZE, &mediasize) != -1)
58
+ mediasize = get_block_device_size(disk.d_fd);
59
+ if (sectorsize && mediasize) {
61
fssize = mediasize / sectorsize;
62
else if (fssize > mediasize / sectorsize)
63
+ mediasize = get_block_device_size(disk.d_fd);
64
+ if (sectorsize && mediasize)
65
getfssize(&fssize, special, mediasize / sectorsize, reserved);
68
@@ -370,7 +380,7 @@ main(int argc, char *argv[])
64
69
pp->p_size *= secperblk;
69
74
if (realsectorsize != DEV_BSIZE)
70
75
pp->p_size /= realsectorsize / DEV_BSIZE;
71
76
if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition)))
77
@@ -415,8 +425,10 @@ getdisklabel(char *s)
76
81
+#if HAVE_BSD_DISKLABEL
77
static struct disklabel lab;
82
if (ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab) != -1)
87
lp = getdiskbyname(disktype);
88
@@ -441,8 +453,10 @@ rewritelabel(char *s, struct disklabel *
89
errx(1, "cannot write label");
91
lp->d_checksum = dkcksum(lp);
92
92
+#if HAVE_BSD_DISKLABEL
93
if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) < 0)
93
if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) == -1)
94
94
warn("ioctl (WDINFO): %s: can't rewrite disk label", s);
102
"usage: %s [ -fsoptions ] special-device%s\n",
106
fprintf(stderr, "where fsoptions are:\n");
107
fprintf(stderr, "\t-J Enable journaling via gjournal\n");
108
Index: ufsutils/mkfs.ufs/Makefile
109
===================================================================
110
--- ufsutils.orig/mkfs.ufs/Makefile
111
+++ ufsutils/mkfs.ufs/Makefile
99
--- a/sbin/newfs/Makefile
100
+++ b/sbin/newfs/Makefile
113
102
# @(#)Makefile 8.2 (Berkeley) 3/27/94
114
# $FreeBSD: src/sbin/newfs/Makefile,v 1.22 2003/02/11 03:06:45 jmallett Exp $
105
-.PATH: ${.CURDIR}/../../sys/geom
117
108
-DPADD= ${LIBUFS}
119
-SRCS= newfs.c mkfs.c
110
-SRCS= newfs.c mkfs.c geom_bsd_enc.c
113
+SRCS= newfs.c mkfs.c ../../sys/geom/geom_bsd_enc.c
123
+SRCS = newfs.c mkfs.c
125
+MAN = newfs.8:mkfs.ufs.8
116
+MAN= newfs.8:mkfs.ufs.8
118
+LDADD += -L../../lib/libufs -lufs -L../../lib/port -lport -lbsd
119
+INCLUDES = -I../../lib/libufs -include ../../lib/port/blockdev.h
127
121
-.include <bsd.prog.mk>
128
+LDADD += -L../libufs -lufs -L../libdisklabel -ldisklabel -L../libport -lport -lbsd
129
+INCLUDES = -I../libufs \
130
+ -include port/blockdev.h
132
+include ../Makefile.common
122
+include ../../Makefile.common
135
125
- sh ${.CURDIR}/runtest01.sh
139
129
+ sh ${CURDIR}/runtest00.sh | tee _.test
140
130
+ diff --ignore-matching-lines=FreeBSD _.test ${CURDIR}/ref.test
141
131
echo All Tests Passed
132
--- a/sbin/newfs/newfs.8
133
+++ b/sbin/newfs/newfs.8
134
@@ -78,10 +78,10 @@ The following options define the general
136
Erase the content of the disk before making the filesystem.
137
The reserved area in front of the superblock (for bootcode) will not be erased.
140
This is a relevant option for flash based storage devices that use
141
wear levelling algorithms.
144
NB: Erasing may take as long time as writing every sector on the disk.
146
Enable journaling on the new file system via gjournal.