MFC - tracking commit.
This commit is contained in:
commit
9dda6bc99f
4
UPDATING
4
UPDATING
@ -31,6 +31,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
|
||||
20131006:
|
||||
RCS has been removed from the base system. If you need RCS
|
||||
install either devel/rcs or devel/rcs57.
|
||||
|
||||
20130930:
|
||||
BIND has been removed from the base system. If all you need
|
||||
is a local resolver, simply enable and start the local_unbound
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <err.h>
|
||||
#include <jail.h>
|
||||
|
||||
#include <libzfs.h>
|
||||
#include <libzfs_core.h>
|
||||
|
@ -6438,14 +6438,22 @@ VMX_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag)
|
||||
static void
|
||||
OP_VMX (int bytemode, int sizeflag)
|
||||
{
|
||||
used_prefixes |= (prefixes & (PREFIX_DATA | PREFIX_REPZ));
|
||||
if (prefixes & PREFIX_DATA)
|
||||
strcpy (obuf, "vmclear");
|
||||
else if (prefixes & PREFIX_REPZ)
|
||||
strcpy (obuf, "vmxon");
|
||||
if (modrm.mod == 3)
|
||||
{
|
||||
strcpy (obuf, "rdrand");
|
||||
OP_E (v_mode, sizeflag);
|
||||
}
|
||||
else
|
||||
strcpy (obuf, "vmptrld");
|
||||
OP_E (bytemode, sizeflag);
|
||||
{
|
||||
used_prefixes |= (prefixes & (PREFIX_DATA | PREFIX_REPZ));
|
||||
if (prefixes & PREFIX_DATA)
|
||||
strcpy (obuf, "vmclear");
|
||||
else if (prefixes & PREFIX_REPZ)
|
||||
strcpy (obuf, "vmxon");
|
||||
else
|
||||
strcpy (obuf, "vmptrld");
|
||||
OP_E (bytemode, sizeflag);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -79,6 +79,7 @@ typedef struct template
|
||||
#define CpuNo64 0x8000000 /* Not supported in the 64bit mode */
|
||||
|
||||
#define CpuPCLMUL 0x10000000 /* Carry-less Multiplication extensions */
|
||||
#define CpuRdRnd 0x20000000 /* Intel Random Number Generator extensions */
|
||||
|
||||
/* SSE4.1/4.2 Instructions required */
|
||||
#define CpuSSE4 (CpuSSE4_1|CpuSSE4_2)
|
||||
@ -87,7 +88,7 @@ typedef struct template
|
||||
#define CpuUnknownFlags (Cpu186|Cpu286|Cpu386|Cpu486|Cpu586|Cpu686 \
|
||||
|CpuP4|CpuSledgehammer|CpuMMX|CpuMMX2|CpuSSE|CpuSSE2|CpuSSE3|CpuVMX \
|
||||
|Cpu3dnow|Cpu3dnowA|CpuK6|CpuPadLock|CpuSVME|CpuSSSE3|CpuSSE4_1 \
|
||||
|CpuSSE4_2|CpuABM|CpuSSE4a|CpuXSAVE|CpuAES|CpuPCLMUL)
|
||||
|CpuSSE4_2|CpuABM|CpuSSE4a|CpuXSAVE|CpuAES|CpuPCLMUL|CpuRdRnd)
|
||||
|
||||
/* the bits in opcode_modifier are used to generate the final opcode from
|
||||
the base_opcode. These bits also are used to detect alternate forms of
|
||||
|
@ -1502,3 +1502,21 @@ xrstor, 1, 0xfae, 0x5, CpuXSAVE, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_xSuf,
|
||||
// INVPCID
|
||||
invpcid, 2, 0x660f3882, None, CpuNo64, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_sSuf|No_qSuf|No_xSuf|NoRex64, { BaseIndex|Disp8|Disp16|Disp32|Disp32S, Reg32 }
|
||||
invpcid, 2, 0x660f3882, None, Cpu64, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_sSuf|No_qSuf|No_xSuf|NoRex64, { BaseIndex|Disp8|Disp16|Disp32|Disp32S, Reg64 }
|
||||
|
||||
// Intel AES extensions
|
||||
aesdec, 2, 0x660f38de, None, CpuAES, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { RegXMM|LLongMem, RegXMM }
|
||||
aesdeclast, 2, 0x660f38df, None, CpuAES, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { RegXMM|LLongMem, RegXMM }
|
||||
aesenc, 2, 0x660f38dc, None, CpuAES, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { RegXMM|LLongMem, RegXMM }
|
||||
aesenclast, 2, 0x660f38dd, None, CpuAES, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { RegXMM|LLongMem, RegXMM }
|
||||
aesimc, 2, 0x660f38db, None, CpuAES, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { RegXMM|LLongMem, RegXMM }
|
||||
aeskeygenassist, 3, 0x660f3adf, None, CpuAES, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { Imm8, RegXMM|LLongMem, RegXMM }
|
||||
|
||||
// Intel Carry-less Multiplication extensions
|
||||
pclmulqdq, 3, 0x660f3a44, None, CpuPCLMUL, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { Imm8, RegXMM|LLongMem, RegXMM }
|
||||
pclmullqlqdq, 2, 0x660f3a44, 0x0, CpuPCLMUL, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf|ImmExt, { RegXMM|LLongMem, RegXMM }
|
||||
pclmulhqlqdq, 2, 0x660f3a44, 0x1, CpuPCLMUL, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf|ImmExt, { RegXMM|LLongMem, RegXMM }
|
||||
pclmullqhqdq, 2, 0x660f3a44, 0x10, CpuPCLMUL, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf|ImmExt, { RegXMM|LLongMem, RegXMM }
|
||||
pclmulhqhqdq, 2, 0x660f3a44, 0x11, CpuPCLMUL, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf|ImmExt, { RegXMM|LLongMem, RegXMM }
|
||||
|
||||
// Intel Random Number Generator extensions
|
||||
rdrand, 1, 0x0fc7, 0x6, CpuRdRnd, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { Reg16|Reg32|Reg64 }
|
||||
|
@ -4374,6 +4374,11 @@ const template i386_optab[] =
|
||||
Modrm|IgnoreSize|NoSuf|ImmExt,
|
||||
{ RegXMM|LLongMem,
|
||||
RegXMM } },
|
||||
|
||||
/* Intel Random Number Generator extensions */
|
||||
{"rdrand", 1, 0x0fc7, 0x6, CpuRdRnd,
|
||||
Modrm|NoSuf,
|
||||
{ Reg16|Reg32|Reg64 } },
|
||||
|
||||
{ NULL, 0, 0, 0, 0, 0, { 0 } }
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ sshd_keygen_alg()
|
||||
fi
|
||||
|
||||
if [ -f "${keyfile}" ] ; then
|
||||
echo "$ALG host key exists."
|
||||
info "$ALG host key exists."
|
||||
else
|
||||
echo "Generating $ALG host key."
|
||||
/usr/bin/ssh-keygen -q -t $alg -f "$keyfile" -N ""
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd Apr 12, 2011
|
||||
.Dd October 7, 2013
|
||||
.Dt HUMANIZE_NUMBER 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -140,7 +140,7 @@ The following flags may be passed in
|
||||
.Fa flags :
|
||||
.Bl -tag -width ".Dv HN_DIVISOR_1000" -offset indent
|
||||
.It Dv HN_DECIMAL
|
||||
If the final result is less than 10, display it using one digit.
|
||||
If the final result is less than 10, display it using one decimal place.
|
||||
.It Dv HN_NOSPACE
|
||||
Do not put a space between
|
||||
.Fa number
|
||||
@ -160,13 +160,18 @@ This flag has no effect when
|
||||
is also specified.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn humanize_number
|
||||
function returns the number of characters stored in
|
||||
Upon success, the
|
||||
.Nm
|
||||
function returns the number of characters that would have been stored in
|
||||
.Fa buf
|
||||
(excluding the terminating
|
||||
.Dv NUL )
|
||||
upon success, or \-1 upon failure.
|
||||
if
|
||||
.Fa buf
|
||||
was large enough, or \-1 upon failure.
|
||||
Even upon failure, the contents of
|
||||
.Fa buf
|
||||
may be modified.
|
||||
If
|
||||
.Dv HN_GETSCALE
|
||||
is specified, the prefix index number will be returned instead.
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright 2013 John-Mark Gurney <jmg@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -50,15 +51,26 @@ humanize_number(char *buf, size_t len, int64_t quotient,
|
||||
{
|
||||
const char *prefixes, *sep;
|
||||
int i, r, remainder, s1, s2, sign;
|
||||
int divisordeccut;
|
||||
int64_t divisor, max;
|
||||
size_t baselen;
|
||||
|
||||
assert(buf != NULL);
|
||||
assert(suffix != NULL);
|
||||
assert(scale >= 0);
|
||||
assert(scale < maxscale || (((scale & (HN_AUTOSCALE | HN_GETSCALE)) != 0)));
|
||||
assert(!((flags & HN_DIVISOR_1000) && (flags & HN_IEC_PREFIXES)));
|
||||
/* Since so many callers don't check -1, NUL terminate the buffer */
|
||||
if (len > 0)
|
||||
buf[0] = '\0';
|
||||
|
||||
/* validate args */
|
||||
if (buf == NULL || suffix == NULL)
|
||||
return (-1);
|
||||
if (scale < 0)
|
||||
return (-1);
|
||||
else if (scale >= maxscale &&
|
||||
((scale & ~(HN_AUTOSCALE|HN_GETSCALE)) != 0))
|
||||
return (-1);
|
||||
if ((flags & HN_DIVISOR_1000) && (flags & HN_IEC_PREFIXES))
|
||||
return (-1);
|
||||
|
||||
/* setup parameters */
|
||||
remainder = 0;
|
||||
|
||||
if (flags & HN_IEC_PREFIXES) {
|
||||
@ -73,34 +85,32 @@ humanize_number(char *buf, size_t len, int64_t quotient,
|
||||
* an assertion earlier).
|
||||
*/
|
||||
divisor = 1024;
|
||||
divisordeccut = 973; /* ceil(.95 * 1024) */
|
||||
if (flags & HN_B)
|
||||
prefixes = "B\0\0Ki\0Mi\0Gi\0Ti\0Pi\0Ei";
|
||||
else
|
||||
prefixes = "\0\0\0Ki\0Mi\0Gi\0Ti\0Pi\0Ei";
|
||||
} else {
|
||||
baselen = 1;
|
||||
if (flags & HN_DIVISOR_1000)
|
||||
if (flags & HN_DIVISOR_1000) {
|
||||
divisor = 1000;
|
||||
else
|
||||
divisordeccut = 950;
|
||||
if (flags & HN_B)
|
||||
prefixes = "B\0\0k\0\0M\0\0G\0\0T\0\0P\0\0E";
|
||||
else
|
||||
prefixes = "\0\0\0k\0\0M\0\0G\0\0T\0\0P\0\0E";
|
||||
} else {
|
||||
divisor = 1024;
|
||||
|
||||
if (flags & HN_B)
|
||||
prefixes = "B\0\0k\0\0M\0\0G\0\0T\0\0P\0\0E";
|
||||
else
|
||||
prefixes = "\0\0\0k\0\0M\0\0G\0\0T\0\0P\0\0E";
|
||||
divisordeccut = 973; /* ceil(.95 * 1024) */
|
||||
if (flags & HN_B)
|
||||
prefixes = "B\0\0K\0\0M\0\0G\0\0T\0\0P\0\0E";
|
||||
else
|
||||
prefixes = "\0\0\0K\0\0M\0\0G\0\0T\0\0P\0\0E";
|
||||
}
|
||||
}
|
||||
|
||||
#define SCALE2PREFIX(scale) (&prefixes[(scale) * 3])
|
||||
|
||||
if (scale < 0 || (scale >= maxscale &&
|
||||
(scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0))
|
||||
return (-1);
|
||||
|
||||
if (buf == NULL || suffix == NULL)
|
||||
return (-1);
|
||||
|
||||
if (len > 0)
|
||||
buf[0] = '\0';
|
||||
if (quotient < 0) {
|
||||
sign = -1;
|
||||
quotient = -quotient;
|
||||
@ -132,8 +142,8 @@ humanize_number(char *buf, size_t len, int64_t quotient,
|
||||
* divide once more.
|
||||
*/
|
||||
for (i = 0;
|
||||
(quotient >= max || (quotient == max - 1 && remainder >= 950)) &&
|
||||
i < maxscale; i++) {
|
||||
(quotient >= max || (quotient == max - 1 &&
|
||||
remainder >= divisordeccut)) && i < maxscale; i++) {
|
||||
remainder = quotient % divisor;
|
||||
quotient /= divisor;
|
||||
}
|
||||
@ -148,20 +158,22 @@ humanize_number(char *buf, size_t len, int64_t quotient,
|
||||
}
|
||||
|
||||
/* If a value <= 9.9 after rounding and ... */
|
||||
if (quotient <= 9 && remainder < 950 && i > 0 && flags & HN_DECIMAL) {
|
||||
/* baselen + \0 + .N */
|
||||
if (len < baselen + 1 + 2)
|
||||
return (-1);
|
||||
s1 = (int)quotient + ((remainder + 50) / 1000);
|
||||
s2 = ((remainder + 50) / 100) % 10;
|
||||
/*
|
||||
* XXX - should we make sure there is enough space for the decimal
|
||||
* place and if not, don't do HN_DECIMAL?
|
||||
*/
|
||||
if (((quotient == 9 && remainder < divisordeccut) || quotient < 9) &&
|
||||
i > 0 && flags & HN_DECIMAL) {
|
||||
s1 = (int)quotient + ((remainder * 10 + divisor / 2) /
|
||||
divisor / 10);
|
||||
s2 = ((remainder * 10 + divisor / 2) / divisor) % 10;
|
||||
r = snprintf(buf, len, "%d%s%d%s%s%s",
|
||||
sign * s1, localeconv()->decimal_point, s2,
|
||||
sep, SCALE2PREFIX(i), suffix);
|
||||
} else
|
||||
r = snprintf(buf, len, "%" PRId64 "%s%s%s",
|
||||
sign * (quotient + (remainder + 50) / 1000),
|
||||
sign * (quotient + (remainder + divisor / 2) / divisor),
|
||||
sep, SCALE2PREFIX(i), suffix);
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ SUBDIR= ${_atf} \
|
||||
bootpd \
|
||||
${_comsat} \
|
||||
fingerd \
|
||||
freebsd-version \
|
||||
ftpd \
|
||||
getty \
|
||||
${_mail.local} \
|
||||
|
21
libexec/freebsd-version/Makefile
Normal file
21
libexec/freebsd-version/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SCRIPTS = freebsd-version
|
||||
MAN = freebsd-version.1
|
||||
BINDIR = /libexec
|
||||
CLEANFILES = freebsd-version.sh
|
||||
NEWVERS = ${.CURDIR}/../../sys/conf/newvers.sh
|
||||
|
||||
freebsd-version.sh.in: ${NEWVERS}
|
||||
freebsd-version.sh: freebsd-version.sh.in
|
||||
eval $$(egrep '^(TYPE|REVISION|BRANCH)=' ${NEWVERS}) ; \
|
||||
if ! sed -e "\
|
||||
s/@@TYPE@@/$${TYPE}/g; \
|
||||
s/@@REVISION@@/$${REVISION}/g; \
|
||||
s/@@BRANCH@@/$${BRANCH}/g; \
|
||||
" ${.ALLSRC} >${.TARGET} ; then \
|
||||
rm -f ${.TARGET} ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
.include <bsd.prog.mk>
|
124
libexec/freebsd-version/freebsd-version.1
Normal file
124
libexec/freebsd-version/freebsd-version.1
Normal file
@ -0,0 +1,124 @@
|
||||
.\"-
|
||||
.\" Copyright (c) 2013 Dag-Erling Smørgrav
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 5, 2013
|
||||
.Dt FREEBSD-VERSION 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm freebsd-version
|
||||
.Nd print the version and patch level of the installed system
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ku
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility makes a best effort to determine the version and patch level
|
||||
of the installed kernel and / or userland.
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width Fl
|
||||
.It Fl k
|
||||
Print the version and patch level of the installed kernel.
|
||||
Unlike
|
||||
.Xr uname 1 ,
|
||||
if a new kernel has been installed but the system has not yet
|
||||
rebooted,
|
||||
.Nm
|
||||
will print the version and patch level of the new kernel.
|
||||
.It Fl u
|
||||
Print the version and patch level of the installed userland.
|
||||
These are hardcoded into
|
||||
.Nm
|
||||
during the build.
|
||||
.El
|
||||
.Pp
|
||||
If both
|
||||
.Fl k
|
||||
and
|
||||
.Fl u
|
||||
are specified,
|
||||
.Nm
|
||||
will print the kernel version first, then the userland version, on
|
||||
separate lines.
|
||||
If neither is specified, it will print the userland version only.
|
||||
.Sh IMPLEMENTATION NOTES
|
||||
The
|
||||
.Nm
|
||||
utility should provide the correct answer in the vast majority of
|
||||
cases, including on systems kept up-to-date using
|
||||
.Xr freebsd-update 8 ,
|
||||
which does not update the kernel version unless the kernel itself was
|
||||
affected by the latest patch.
|
||||
.Pp
|
||||
To determine the name (and hence the location) of a custom kernel, the
|
||||
.Nm
|
||||
utility will attempt to parse
|
||||
.Pa /boot/defaults/loader.conf
|
||||
and
|
||||
.Pa /boot/loader.conf ,
|
||||
looking for definitions of the
|
||||
.Va kernel
|
||||
and
|
||||
.Va bootfile
|
||||
variables, both with a default value of
|
||||
.Dq kernel .
|
||||
It may however fail to locate the correct kernel if either or both of
|
||||
these variables are defined in a non-standard location, such as in
|
||||
.Pa /boot/loader.rc .
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width ROOT
|
||||
.It Ev ROOT
|
||||
Path to the root of the filesystem in which to look for
|
||||
.Pa loader.conf
|
||||
and the kernel.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
To determine the version of the currently running userland:
|
||||
.Bd -literal -offset indent
|
||||
/libexec/freebsd-version -u
|
||||
.Ed
|
||||
.Pp
|
||||
To inspect a system being repaired using a live CD:
|
||||
.Bd -literal -offset indent
|
||||
mount -rt ufs /dev/ada0p2 /mnt
|
||||
env ROOT=/mnt /mnt/libexec/freebsd-version -ku
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr uname 1 ,
|
||||
.Xr loader.conf 5 ,
|
||||
.Xr freebsd-version 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
command appeared in
|
||||
.Fx 10.0 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility and this manual page were written by
|
||||
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
|
126
libexec/freebsd-version/freebsd-version.sh.in
Normal file
126
libexec/freebsd-version/freebsd-version.sh.in
Normal file
@ -0,0 +1,126 @@
|
||||
#!/bin/sh
|
||||
#-
|
||||
# Copyright (c) 2013 Dag-Erling Smørgrav
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
USERLAND_VERSION="@@REVISION@@-@@BRANCH@@"
|
||||
|
||||
: ${ROOT:=}
|
||||
: ${LOADER_DIR:=$ROOT/boot}
|
||||
: ${LOADER_CONF_FILES:=$LOADER_DIR/defaults/loader.conf $LOADER_DIR/loader.conf $LOADER_DIR/loader.conf.local}
|
||||
LOADER_RE1='^\([A-Z_a-z][0-9A-Z_a-z]*=[-./0-9A-Z_a-z]\{1,\}\).*$'
|
||||
LOADER_RE2='^\([A-Z_a-z][0-9A-Z_a-z]*="[-./0-9A-Z_a-z]\{1,\}"\).*$'
|
||||
KERNEL_RE='^@(#)@@TYPE@@ \([-.0-9A-Za-z]\{1,\}\) .*$'
|
||||
|
||||
progname=$(basename $0)
|
||||
|
||||
#
|
||||
# Print an error message and exit.
|
||||
#
|
||||
error() {
|
||||
echo "$progname: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# Try to get the name of the installed kernel from loader.conf and
|
||||
# return the full path. If loader.conf does not exist or we could not
|
||||
# read it, return the path to the default kernel.
|
||||
#
|
||||
kernel_file() {
|
||||
eval $(sed -n "s/$LOADER_RE1/\\1;/p; s/$LOADER_RE2/\\1;/p" \
|
||||
$LOADER_CONF_FILES 2>/dev/null)
|
||||
echo "$LOADER_DIR/${kernel:-kernel}/${bootfile:-kernel}"
|
||||
}
|
||||
|
||||
#
|
||||
# Extract the kernel version from the installed kernel.
|
||||
#
|
||||
kernel_version() {
|
||||
kernfile=$(kernel_file)
|
||||
if [ ! -f "$kernfile" -o ! -r "$kernfile" ] ; then
|
||||
error "unable to locate kernel"
|
||||
fi
|
||||
strings "$kernfile" | sed -n "s/$KERNEL_RE/\\1/p"
|
||||
}
|
||||
|
||||
#
|
||||
# Print the hardcoded userland version.
|
||||
#
|
||||
userland_version() {
|
||||
echo $USERLAND_VERSION
|
||||
}
|
||||
|
||||
#
|
||||
# Print a usage string and exit.
|
||||
#
|
||||
usage() {
|
||||
echo "usage: $progname [-ku]\n" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# Main program.
|
||||
#
|
||||
main() {
|
||||
# parse command-line arguments
|
||||
while getopts "ku" option ; do
|
||||
case $option in
|
||||
k)
|
||||
opt_k=1
|
||||
;;
|
||||
u)
|
||||
opt_u=1
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ $OPTIND -le $# ] ; then
|
||||
usage
|
||||
fi
|
||||
|
||||
# default is -u
|
||||
if [ $((opt_k + opt_u)) -eq 0 ] ; then
|
||||
opt_u=1
|
||||
fi
|
||||
|
||||
# print kernel version
|
||||
if [ $opt_k ] ; then
|
||||
kernel_version
|
||||
fi
|
||||
|
||||
# print userland version
|
||||
if [ $opt_u ] ; then
|
||||
userland_version
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
@ -116,6 +116,7 @@ static Objlist_Entry *objlist_find(Objlist *, const Obj_Entry *);
|
||||
static void objlist_init(Objlist *);
|
||||
static void objlist_push_head(Objlist *, Obj_Entry *);
|
||||
static void objlist_push_tail(Objlist *, Obj_Entry *);
|
||||
static void objlist_put_after(Objlist *, Obj_Entry *, Obj_Entry *);
|
||||
static void objlist_remove(Objlist *, Obj_Entry *);
|
||||
static void *path_enumerate(const char *, path_enum_proc, void *);
|
||||
static int relocate_object_dag(Obj_Entry *root, bool bind_now,
|
||||
@ -323,6 +324,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
|
||||
Objlist_Entry *entry;
|
||||
Obj_Entry *obj;
|
||||
Obj_Entry **preload_tail;
|
||||
Obj_Entry *last_interposer;
|
||||
Objlist initlist;
|
||||
RtldLockState lockstate;
|
||||
char *library_path_rpath;
|
||||
@ -537,8 +539,14 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
|
||||
die();
|
||||
|
||||
/* Make a list of all objects loaded at startup. */
|
||||
last_interposer = obj_main;
|
||||
for (obj = obj_list; obj != NULL; obj = obj->next) {
|
||||
objlist_push_tail(&list_main, obj);
|
||||
if (obj->z_interpose && obj != obj_main) {
|
||||
objlist_put_after(&list_main, last_interposer, obj);
|
||||
last_interposer = obj;
|
||||
} else {
|
||||
objlist_push_tail(&list_main, obj);
|
||||
}
|
||||
obj->refcount++;
|
||||
}
|
||||
|
||||
@ -1128,6 +1136,8 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
|
||||
obj->z_nodelete = true;
|
||||
if (dynp->d_un.d_val & DF_1_LOADFLTR)
|
||||
obj->z_loadfltr = true;
|
||||
if (dynp->d_un.d_val & DF_1_INTERPOSE)
|
||||
obj->z_interpose = true;
|
||||
if (dynp->d_un.d_val & DF_1_NODEFLIB)
|
||||
obj->z_nodeflib = true;
|
||||
break;
|
||||
@ -1976,6 +1986,7 @@ static int
|
||||
load_preload_objects(void)
|
||||
{
|
||||
char *p = ld_preload;
|
||||
Obj_Entry *obj;
|
||||
static const char delim[] = " \t:;";
|
||||
|
||||
if (p == NULL)
|
||||
@ -1988,8 +1999,10 @@ load_preload_objects(void)
|
||||
|
||||
savech = p[len];
|
||||
p[len] = '\0';
|
||||
if (load_object(p, -1, NULL, 0) == NULL)
|
||||
obj = load_object(p, -1, NULL, 0);
|
||||
if (obj == NULL)
|
||||
return -1; /* XXX - cleanup */
|
||||
obj->z_interpose = true;
|
||||
p[len] = savech;
|
||||
p += len;
|
||||
p += strspn(p, delim);
|
||||
@ -2377,6 +2390,23 @@ objlist_push_tail(Objlist *list, Obj_Entry *obj)
|
||||
STAILQ_INSERT_TAIL(list, elm, link);
|
||||
}
|
||||
|
||||
static void
|
||||
objlist_put_after(Objlist *list, Obj_Entry *listobj, Obj_Entry *obj)
|
||||
{
|
||||
Objlist_Entry *elm, *listelm;
|
||||
|
||||
STAILQ_FOREACH(listelm, list, link) {
|
||||
if (listelm->obj == listobj)
|
||||
break;
|
||||
}
|
||||
elm = NEW(Objlist_Entry);
|
||||
elm->obj = obj;
|
||||
if (listelm != NULL)
|
||||
STAILQ_INSERT_AFTER(list, listelm, elm, link);
|
||||
else
|
||||
STAILQ_INSERT_TAIL(list, elm, link);
|
||||
}
|
||||
|
||||
static void
|
||||
objlist_remove(Objlist *list, Obj_Entry *obj)
|
||||
{
|
||||
|
@ -259,6 +259,7 @@ typedef struct Struct_Obj_Entry {
|
||||
bool z_nodelete : 1; /* Do not unload the object and dependencies */
|
||||
bool z_noopen : 1; /* Do not load on dlopen */
|
||||
bool z_loadfltr : 1; /* Immediately load filtees */
|
||||
bool z_interpose : 1; /* Interpose all objects but main */
|
||||
bool z_nodeflib : 1; /* Don't search default library path */
|
||||
bool ref_nodel : 1; /* Refcount increased to prevent dlclose */
|
||||
bool init_scanned: 1; /* Object is already on init list. */
|
||||
|
@ -2748,7 +2748,7 @@ atasecurity(struct cam_device *device, int retry_count, int timeout,
|
||||
if (strcasecmp(optarg, "user") == 0) {
|
||||
pwd.ctrl |= ATA_SECURITY_PASSWORD_USER;
|
||||
pwd.ctrl &= ~ATA_SECURITY_PASSWORD_MASTER;
|
||||
} else if (strcasecmp(optarg, "master") != 0) {
|
||||
} else if (strcasecmp(optarg, "master") == 0) {
|
||||
pwd.ctrl |= ATA_SECURITY_PASSWORD_MASTER;
|
||||
pwd.ctrl &= ~ATA_SECURITY_PASSWORD_USER;
|
||||
} else {
|
||||
|
@ -224,6 +224,7 @@ fw_read_img(const char *fw_img_path, const struct fw_vendor *vp, int *num_bytes)
|
||||
goto bailout;
|
||||
}
|
||||
*num_bytes = img_size;
|
||||
close(fd);
|
||||
return (buf);
|
||||
bailout:
|
||||
free(buf);
|
||||
@ -286,6 +287,7 @@ fw_download_img(struct cam_device *cam_dev, const struct fw_vendor *vp,
|
||||
ata_28bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0);
|
||||
} else {
|
||||
warnx("weird disk type '%s'", type);
|
||||
cam_freeccb(ccb);
|
||||
return 1;
|
||||
}
|
||||
/* Disable freezing the device queue. */
|
||||
|
@ -56,11 +56,11 @@ entries configure the address, size, I/O disposition, and
|
||||
.Pa /dev
|
||||
device node name that will be used.
|
||||
The
|
||||
.Xr open ,
|
||||
.Xr read ,
|
||||
.Xr write ,
|
||||
.Xr open 2 ,
|
||||
.Xr read 2 ,
|
||||
.Xr write 2 ,
|
||||
and
|
||||
.Xr mmap
|
||||
.Xr mmap 2
|
||||
system calls (and variations) may be used on
|
||||
.Nm
|
||||
device nodes, subject to constraints imposed using
|
||||
|
@ -35,9 +35,9 @@ place the following lines in your kernel configuration file:
|
||||
.Pp
|
||||
Alternatively, to load the driver as a module at boot time,
|
||||
place the following line in
|
||||
.Xr loader.conf 5:
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
.Xr if_rsu_load="YES"
|
||||
if_rsu_load="YES"
|
||||
.Ed
|
||||
.Pp
|
||||
After you have read the license in /usr/share/doc/legal/realtek
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" DO NOT EDIT-- this file is automatically generated.
|
||||
.\" from FreeBSD: head/tools/build/options/makeman 253304 2013-07-12 23:08:44Z bapt
|
||||
.\" from FreeBSD: head/tools/build/options/makeman 255964 2013-10-01 07:22:04Z des
|
||||
.\" $FreeBSD$
|
||||
.Dd September 30, 2013
|
||||
.Dd October 6, 2013
|
||||
.Dt SRC.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -200,7 +200,7 @@ When set, it also enforces the following options:
|
||||
Set to not build the Clang C/C++ compiler.
|
||||
.Pp
|
||||
It is a default setting on
|
||||
arm/armeb, arm/armv6eb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and sparc64/sparc64.
|
||||
arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and sparc64/sparc64.
|
||||
When set, it also enforces the following options:
|
||||
.Pp
|
||||
.Bl -item -compact
|
||||
@ -228,7 +228,7 @@ Set to avoid building the ARCMigrate, Rewriter and StaticAnalyzer components of
|
||||
the Clang C/C++ compiler.
|
||||
.Pp
|
||||
It is a default setting on
|
||||
arm/arm, arm/armeb, arm/armv6, arm/armv6eb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and sparc64/sparc64.
|
||||
arm/arm, arm/armeb, arm/armv6, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and sparc64/sparc64.
|
||||
.It Va WITH_CLANG_FULL
|
||||
.\" from FreeBSD: head/tools/build/options/WITH_CLANG_FULL 246259 2013-02-02 22:28:29Z dim
|
||||
Set to build the ARCMigrate, Rewriter and StaticAnalyzer components of the
|
||||
@ -245,7 +245,7 @@ and
|
||||
.Pa /usr/bin/cpp .
|
||||
.Pp
|
||||
It is a default setting on
|
||||
arm/armeb, arm/armv6eb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
When set, it also enforces the following options:
|
||||
.Pp
|
||||
.Bl -item -compact
|
||||
@ -369,7 +369,7 @@ Set to build Flattened Device Tree support as part of the base system.
|
||||
This includes the device tree compiler (dtc) and libfdt support library.
|
||||
.Pp
|
||||
It is a default setting on
|
||||
arm/arm, arm/armeb, arm/armv6, arm/armv6eb, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc and powerpc/powerpc64.
|
||||
arm/arm, arm/armeb, arm/armv6, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc and powerpc/powerpc64.
|
||||
.It Va WITHOUT_FLOPPY
|
||||
.\" from FreeBSD: head/tools/build/options/WITHOUT_FLOPPY 221540 2011-05-06 19:13:03Z ru
|
||||
Set to not build or install programs
|
||||
@ -406,7 +406,7 @@ amd64/amd64, arm/arm, arm/armv6 and i386/i386.
|
||||
Set to build and install gcc and g++.
|
||||
.Pp
|
||||
It is a default setting on
|
||||
arm/armeb, arm/armv6eb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
.It Va WITHOUT_GCOV
|
||||
.\" from FreeBSD: head/tools/build/options/WITHOUT_GCOV 156932 2006-03-21 07:50:50Z ru
|
||||
Set to not build the
|
||||
@ -443,7 +443,7 @@ Build the GNU C++ stack (g++, libstdc++).
|
||||
This is the default on platforms where gcc is the system compiler.
|
||||
.Pp
|
||||
It is a default setting on
|
||||
arm/armeb, arm/armv6eb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
.It Va WITHOUT_GNU_SUPPORT
|
||||
.\" from FreeBSD: head/tools/build/options/WITHOUT_GNU_SUPPORT 156932 2006-03-21 07:50:50Z ru
|
||||
Set to build some programs without optional GNU support.
|
||||
@ -909,11 +909,6 @@ This includes
|
||||
.Xr rlogin 1 ,
|
||||
.Xr rsh 1 ,
|
||||
etc.
|
||||
.It Va WITHOUT_RCS
|
||||
.\" from FreeBSD: head/tools/build/options/WITHOUT_RCS 156932 2006-03-21 07:50:50Z ru
|
||||
Set to not build
|
||||
.Xr rcs 1
|
||||
and related utilities.
|
||||
.It Va WITHOUT_RESCUE
|
||||
.\" from FreeBSD: head/tools/build/options/WITHOUT_RESCUE 156932 2006-03-21 07:50:50Z ru
|
||||
Set to not build
|
||||
|
@ -20,7 +20,7 @@ utility is a script which produces a minimal implementation of
|
||||
which typically fits on a small media such as a floppy disk,
|
||||
or can be downloaded as a
|
||||
single image file from some media such as CDROM, flash memory, or through
|
||||
.Xr etherboot .
|
||||
etherboot.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
@ -64,7 +64,7 @@ kernel.
|
||||
This is the default behaviour, and is
|
||||
extremely useful as the kernel itself can be loaded,
|
||||
using
|
||||
.Xr etherboot
|
||||
etherboot
|
||||
or
|
||||
.Xr pxeboot 8 ,
|
||||
.\"
|
||||
@ -378,9 +378,7 @@ If the build is successful, the directory
|
||||
.Pa build_dir-bridge/
|
||||
will contain a
|
||||
.Pa kernel
|
||||
that can be downloaded with
|
||||
.Xr etherboot ,
|
||||
a floppy image called
|
||||
that can be downloaded with etherboot, a floppy image called
|
||||
.Pa picobsd.bin ,
|
||||
plus the products of the compilation in other directories.
|
||||
If you want to modify the source tree in
|
||||
@ -480,9 +478,7 @@ Booting from a floppy is normally rather slow (in the order of 1-2
|
||||
minutes), things are much faster if you store your image on
|
||||
a hard disk, Compact Flash, or CDROM.
|
||||
.Pp
|
||||
You can also use
|
||||
.Xr etherboot
|
||||
to load the preloaded, uncompressed kernel image
|
||||
You can also use etherboot to load the preloaded, uncompressed kernel image
|
||||
which is a byproduct of the
|
||||
.Nm
|
||||
build.
|
||||
|
@ -343,7 +343,9 @@ MAN= accept_filter.9 \
|
||||
vnode.9 \
|
||||
VOP_ACCESS.9 \
|
||||
VOP_ACLCHECK.9 \
|
||||
VOP_ADVISE.9 \
|
||||
VOP_ADVLOCK.9 \
|
||||
VOP_ALLOCATE.9 \
|
||||
VOP_ATTRIB.9 \
|
||||
VOP_BWRITE.9 \
|
||||
VOP_CREATE.9 \
|
||||
|
88
share/man/man9/VOP_ADVISE.9
Normal file
88
share/man/man9/VOP_ADVISE.9
Normal file
@ -0,0 +1,88 @@
|
||||
.\" -*- nroff -*-
|
||||
.\"
|
||||
.\" Copyright (c) 2013 Advanced Computing Technologies LLC
|
||||
.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 3, 2013
|
||||
.Dt VOP_ADVISE 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm VOP_ADVISE
|
||||
.Nd apply advice about use of file data
|
||||
.Sh SYNOPSIS
|
||||
.In sys/param.h
|
||||
.In sys/vnode.h
|
||||
.Ft int
|
||||
.Fn VOP_ADVISE "struct vnode *vp" "off_t start" "off_t end" "int advice"
|
||||
.Sh DESCRIPTION
|
||||
This call applies advice for a range of a file's data.
|
||||
It is used to implement the
|
||||
.Xr posix_fadvise
|
||||
system call.
|
||||
.Pp
|
||||
Its arguments are:
|
||||
.Bl -tag -width offset
|
||||
.It Fa vp
|
||||
The vnode of the file.
|
||||
.It Fa start
|
||||
The start of the range of file data.
|
||||
.It Fa end
|
||||
The end of the range of file data.
|
||||
.It Fa advice
|
||||
The type of operation to apply to the file data.
|
||||
Possible values are:
|
||||
.Bl -tag -width POSIX_FADV_WILLNEED
|
||||
.It Dv POSIX_FADV_WILLNEED
|
||||
Initiate an asynchronous read of the file data if it is not already resident.
|
||||
.It Dv POSIX_FADV_DONTNEED
|
||||
Decrease the in-memory priority of clean file data or discard clean file data.
|
||||
.El
|
||||
.El
|
||||
.Pp
|
||||
If the
|
||||
.Fa start
|
||||
and
|
||||
.Fa end
|
||||
offsets are both zero,
|
||||
then the operation should be applied to the entire file.
|
||||
Note that this call is advisory only and may perform the requested
|
||||
operation on a subset of the requested range
|
||||
.Pq including not performing it at all
|
||||
and still return success.
|
||||
.Sh LOCKS
|
||||
The file should be unlocked on entry.
|
||||
.Sh RETURN VALUES
|
||||
Zero is returned if the call is successful, otherwise an appropriate
|
||||
error code is returned.
|
||||
.Sh ERRORS
|
||||
.Bl -tag -width Er
|
||||
.It Bq Er EINVAL
|
||||
An invalid value was given for
|
||||
.Fa advice .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr vnode 9
|
84
share/man/man9/VOP_ALLOCATE.9
Normal file
84
share/man/man9/VOP_ALLOCATE.9
Normal file
@ -0,0 +1,84 @@
|
||||
.\" -*- nroff -*-
|
||||
.\"
|
||||
.\" Copyright (c) 2013 Advanced Computing Technologies LLC
|
||||
.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 3, 2013
|
||||
.Dt VOP_ALLOCATE 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm VOP_ALLOCATE
|
||||
.Nd allocate storage for a file
|
||||
.Sh SYNOPSIS
|
||||
.In sys/param.h
|
||||
.In sys/vnode.h
|
||||
.Ft int
|
||||
.Fn VOP_ALLOCATE "struct vnode *vp" "off_t *offset" "off_t *len"
|
||||
.Sh DESCRIPTION
|
||||
This call allocates storage for a range of offsets in a file.
|
||||
It is used to implement the
|
||||
.Xr posix_fallocate
|
||||
system call.
|
||||
.Pp
|
||||
Its arguments are:
|
||||
.Bl -tag -width offset
|
||||
.It Fa vp
|
||||
The vnode of the file.
|
||||
.It Fa offset
|
||||
The start of the range to allocate storage for in the file.
|
||||
.It Fa len
|
||||
The length of the range to allocate storage for in the file.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Fa offset
|
||||
and
|
||||
.Fa len
|
||||
arguments are updated to reflect the portion of the range that
|
||||
still needs to be allocated on return.
|
||||
A partial allocation is considered a successful operation.
|
||||
The file's contents are not changed.
|
||||
.Sh LOCKS
|
||||
The file should be exclusively locked on entry and will still be locked on exit.
|
||||
.Sh RETURN VALUES
|
||||
Zero is returned if the call is successful, otherwise an appropriate
|
||||
error code is returned.
|
||||
.Sh ERRORS
|
||||
.Bl -tag -width Er
|
||||
.It Bq Er EFBIG
|
||||
An attempt was made to write a file that exceeds the process's file size
|
||||
limit or the maximum file size.
|
||||
.It Bq Er ENOSPC
|
||||
The file system is full.
|
||||
.It Bq Er EPERM
|
||||
An append-only flag is set on the file, but the caller is attempting to
|
||||
write before the current end of file.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr vnode 9 ,
|
||||
.Xr VOP_READ 9 ,
|
||||
.Xr VOP_WRITE 9
|
@ -65,15 +65,6 @@ Push data not written by file system syncer.
|
||||
.It Fa td
|
||||
The calling thread.
|
||||
.El
|
||||
.Pp
|
||||
The argument
|
||||
.Fa waitfor
|
||||
is either
|
||||
.Dv MNT_WAIT
|
||||
or
|
||||
.Dv MNT_NOWAIT
|
||||
and specifies whether or not the function should wait for the writes
|
||||
to finish before returning.
|
||||
.Sh LOCKS
|
||||
The file should be locked on entry.
|
||||
.Sh RETURN VALUES
|
||||
|
@ -254,8 +254,8 @@ IxNpeMicrocode.dat optional npe_fw \\
|
||||
.Pp
|
||||
Note that generating the firmware modules in this way requires
|
||||
the availability of the following tools:
|
||||
.Xr awk ,
|
||||
.Xr make ,
|
||||
.Xr awk 1 ,
|
||||
.Xr make 1 ,
|
||||
the compiler and the linker.
|
||||
.Sh SEE ALSO
|
||||
.Xr kld 4 ,
|
||||
|
@ -64,7 +64,7 @@ function sleeps for any reason, the object lock is temporary dropped.
|
||||
The
|
||||
.Fn vm_page_grab
|
||||
supports all of the flags supported by
|
||||
.Xr vm_page_alloc .
|
||||
.Xr vm_page_alloc 9 .
|
||||
In addition,
|
||||
.Fn vm_page_grab
|
||||
supports the following flags:
|
||||
|
@ -163,7 +163,9 @@ intertwining of VM Objects and Vnodes.
|
||||
.Xr malloc 9 ,
|
||||
.Xr VOP_ACCESS 9 ,
|
||||
.Xr VOP_ACLCHECK 9 ,
|
||||
.Xr VOP_ADVISE 9 ,
|
||||
.Xr VOP_ADVLOCK 9 ,
|
||||
.Xr VOP_ALLOCATE 9 ,
|
||||
.Xr VOP_ATTRIB 9 ,
|
||||
.Xr VOP_BWRITE 9 ,
|
||||
.Xr VOP_CREATE 9 ,
|
||||
|
@ -270,17 +270,23 @@ FreeBSD 5.2 | | | |
|
||||
| | | | | | \ | |
|
||||
| | | | | | NetBSD | |
|
||||
| | | | | | 6.0.1 | |
|
||||
| | | | | | | | |
|
||||
| | | | | | NetBSD | |
|
||||
| | | | | | 6.0.2 | |
|
||||
| | | | | | | OpenBSD 5.3 DragonFly 3.4.1
|
||||
| | | | | | NetBSD | |
|
||||
| | | | | | 6.0.2 | |
|
||||
| | | | | | | |
|
||||
| | | | | `-NetBSD 6.1 | |
|
||||
| | FreeBSD | | | |
|
||||
| | 8.4 | | | |
|
||||
| | | | | |
|
||||
| FreeBSD | | | |
|
||||
| | | | | |`-NetBSD 6.1 | |
|
||||
| | FreeBSD | | | | |
|
||||
| | 8.4 | | NetBSD 6.1.1 | |
|
||||
| | | | | | |
|
||||
| FreeBSD | | NetBSD 6.1.2 | |
|
||||
| 9.2 | | | |
|
||||
| | | | |
|
||||
| | | | |
|
||||
| | | | |
|
||||
| | | | |
|
||||
FreeBSD 10 -current | NetBSD -current OpenBSD -current |
|
||||
| | | | |
|
||||
v v v v v
|
||||
@ -588,9 +594,12 @@ OpenBSD 5.3 2013-05-01 [OBD]
|
||||
NetBSD 6.0.2 2013-05-18 [NBD] (security/critical release)
|
||||
NetBSD 6.1 2013-05-18 [NBD]
|
||||
FreeBSD 8.4 2013-06-07 [FBD]
|
||||
NetBSD 6.1.1 2013-08-22 [NBD]
|
||||
NetBSD 5.1.3 2013-09-29 [NBD]
|
||||
NetBSD 5.2.1 2013-09-29 [NBD]
|
||||
FreeBSD 9.2 2013-09-30 [FBD]
|
||||
NetBSD 6.0.3 2013-09-30 [NBD]
|
||||
NetBSD 6.1.2 2013-09-30 [NBD]
|
||||
|
||||
Bibliography
|
||||
------------------------
|
||||
|
@ -117,7 +117,9 @@ lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
|
||||
src += 2;
|
||||
if ((cpy = dst - offset) < (uchar_t *)d_start)
|
||||
return (-1);
|
||||
while (--mlen >= 0 && dst < d_end)
|
||||
if (mlen > (d_end - dst))
|
||||
mlen = d_end - dst;
|
||||
while (--mlen >= 0)
|
||||
*dst++ = *cpy++;
|
||||
} else {
|
||||
*dst++ = *src++;
|
||||
|
@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <machine/md_var.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/t4_regs.h"
|
||||
@ -215,10 +216,6 @@ static int handle_fw_msg(struct sge_iq *, const struct rss_header *,
|
||||
|
||||
static int sysctl_uint16(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
#if defined(__i386__) || defined(__amd64__)
|
||||
extern u_int cpu_clflush_line_size;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Called on MOD_LOAD. Validates and calculates the SGE tunables.
|
||||
*/
|
||||
|
@ -84,6 +84,7 @@ static driver_t isci_pci_driver = {
|
||||
};
|
||||
|
||||
DRIVER_MODULE(isci, pci, isci_pci_driver, isci_devclass, 0, 0);
|
||||
MODULE_DEPEND(isci, cam, 1, 1, 1);
|
||||
|
||||
static struct _pcsid
|
||||
{
|
||||
|
@ -371,6 +371,7 @@ xctrl_suspend()
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
#ifdef SMP
|
||||
CPU_ZERO(&cpu_suspend_map); /* silence gcc */
|
||||
if (smp_started) {
|
||||
/*
|
||||
* Suspend other CPUs. This prevents IPIs while we
|
||||
|
@ -54,8 +54,6 @@ MODULE_VERSION(ibcs2, 1);
|
||||
|
||||
extern int bsd_to_ibcs2_errno[];
|
||||
extern struct sysent ibcs2_sysent[IBCS2_SYS_MAXSYSCALL];
|
||||
extern int szsigcode;
|
||||
extern char sigcode[];
|
||||
static int ibcs2_fixup(register_t **, struct image_params *);
|
||||
|
||||
struct sysentvec ibcs2_svr3_sysvec = {
|
||||
|
@ -37,9 +37,6 @@
|
||||
/* Everything below this point is not included by assembler (.S) files. */
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* Force a proper event-channel callback from Xen. */
|
||||
void force_evtchn_callback(void);
|
||||
|
||||
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
|
||||
static inline void rep_nop(void)
|
||||
{
|
||||
|
@ -616,7 +616,7 @@ X_ip6_mrouter_done(void)
|
||||
for (rte = rt->mf6c_stall; rte != NULL; ) {
|
||||
struct rtdetq *n = rte->next;
|
||||
|
||||
m_free(rte->m);
|
||||
m_freem(rte->m);
|
||||
free(rte, M_MRTABLE6);
|
||||
rte = n;
|
||||
}
|
||||
|
@ -660,7 +660,7 @@ struct ib_qp_init_attr {
|
||||
union {
|
||||
struct ib_qp *qpg_parent; /* see qpg_type */
|
||||
struct ib_qpg_init_attrib parent_attrib;
|
||||
};
|
||||
} pp;
|
||||
enum ib_sig_type sq_sig_type;
|
||||
enum ib_qp_type qp_type;
|
||||
enum ib_qp_create_flags create_flags;
|
||||
|
@ -487,6 +487,7 @@ typedef struct {
|
||||
#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */
|
||||
#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */
|
||||
#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */
|
||||
#define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */
|
||||
#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */
|
||||
|
||||
/* Values for n_type. Used in core files. */
|
||||
|
@ -64,6 +64,8 @@ typedef __va_list va_list;
|
||||
(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
|
||||
#define va_start(ap, last) \
|
||||
((ap) = (va_list)&(last) + __va_size(last))
|
||||
#define va_copy(dst, src) \
|
||||
((dst) = (src))
|
||||
#define va_arg(ap, type) \
|
||||
(*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
|
||||
#define va_end(ap)
|
||||
|
@ -1,6 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
TESTS= test-trimdomain test-trimdomain-nodomain test-flopen test-grp test-pidfile
|
||||
TESTS= test-trimdomain test-trimdomain-nodomain test-flopen test-grp \
|
||||
test-pidfile test-humanize_number
|
||||
CFLAGS+= -g -Wall -Wextra -Werror -lutil
|
||||
|
||||
.PHONY: tests
|
||||
|
592
tools/regression/lib/libutil/test-humanize_number.c
Normal file
592
tools/regression/lib/libutil/test-humanize_number.c
Normal file
@ -0,0 +1,592 @@
|
||||
/*-
|
||||
* Copyright 2012 Clifton Royston
|
||||
* Copyright 2013 John-Mark Gurney
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <libutil.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
extern char * optarg;
|
||||
|
||||
#define MAX_STR_FLAGS_RESULT 80
|
||||
#define MAX_INT_STR_DIGITS 12
|
||||
|
||||
static const int64_t halfExabyte = (int64_t)500*1000*1000*1000*1000*1000L;
|
||||
|
||||
static struct {
|
||||
int retval;
|
||||
const char *res;
|
||||
int64_t num;
|
||||
int flags;
|
||||
int scale;
|
||||
} test_args[] = {
|
||||
/* tests 0-13 test 1000 suffixes */
|
||||
{ 2, "0 ", (int64_t)0L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 k", (int64_t)500L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 M", (int64_t)500*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 G", (int64_t)500*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 T", (int64_t)500*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 P", (int64_t)500*1000*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 E", (int64_t)500*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 2, "1 ", (int64_t)1L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "2 k", (int64_t)1500L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "2 M", (int64_t)1500*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "2 G", (int64_t)1500*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "2 T", (int64_t)1500*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "2 P", (int64_t)1500*1000*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "2 E", (int64_t)1500*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
|
||||
/* tests 14-27 test 1024 suffixes */
|
||||
{ 2, "0 ", (int64_t)0L, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 K", (int64_t)512L, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 M", (int64_t)512*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 G", (int64_t)512*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 T", (int64_t)512*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 P", (int64_t)512*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 E", (int64_t)512*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 2, "1 ", (int64_t)1L, 0, HN_AUTOSCALE },
|
||||
{ 3, "2 K", (int64_t)1536L, 0, HN_AUTOSCALE },
|
||||
{ 3, "2 M", (int64_t)1536*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "2 G", (int64_t)1536*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "2 T", (int64_t)1536*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "2 P", (int64_t)1536*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "2 E", (int64_t)1536*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
|
||||
/* tests 28-37 test rounding */
|
||||
{ 3, "0 M", (int64_t)500*1000L-1, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 M", (int64_t)500*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "1 M", (int64_t)1000*1000L + 500*1000L-1, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "2 M", (int64_t)1000*1000L + 500*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 3, "0 K", (int64_t)512L-1, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 K", (int64_t)512L, 0, HN_AUTOSCALE },
|
||||
{ 3, "0 M", (int64_t)512*1024L-1, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 M", (int64_t)512*1024L, 0, HN_AUTOSCALE },
|
||||
{ 3, "1 M", (int64_t)1024*1024L + 512*1024L-1, 0, HN_AUTOSCALE },
|
||||
{ 3, "2 M", (int64_t)1024*1024L + 512*1024L, 0, HN_AUTOSCALE },
|
||||
|
||||
/* tests 38-61 test specific scale factors with 1000 divisor */
|
||||
{ 3, "0 k", (int64_t)0L, HN_DIVISOR_1000, 1 },
|
||||
{ 3, "1 k", (int64_t)500L, HN_DIVISOR_1000, 1 },
|
||||
{ 3, "0 M", (int64_t)500L, HN_DIVISOR_1000, 2 },
|
||||
{ 3, "1 M", (int64_t)500*1000L, HN_DIVISOR_1000, 2 },
|
||||
{ 3, "0 G", (int64_t)500*1000L, HN_DIVISOR_1000, 3 },
|
||||
{ 3, "1 G", (int64_t)500*1000*1000L, HN_DIVISOR_1000, 3 },
|
||||
{ 3, "0 T", (int64_t)500*1000*1000L, HN_DIVISOR_1000, 4 },
|
||||
{ 3, "1 T", (int64_t)500*1000*1000*1000L, HN_DIVISOR_1000, 4 },
|
||||
{ 3, "0 P", (int64_t)500*1000*1000*1000L, HN_DIVISOR_1000, 5 },
|
||||
{ 3, "1 P", (int64_t)500*1000*1000*1000*1000L, HN_DIVISOR_1000, 5 },
|
||||
{ 3, "0 E", (int64_t)500*1000*1000*1000*1000L, HN_DIVISOR_1000, 6 },
|
||||
{ 3, "1 E", (int64_t)500*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, 6 },
|
||||
{ 3, "0 k", (int64_t)1L, HN_DIVISOR_1000, 1 },
|
||||
{ 3, "2 k", (int64_t)1500L, HN_DIVISOR_1000, 1 },
|
||||
{ 3, "0 M", (int64_t)1500L, HN_DIVISOR_1000, 2 },
|
||||
{ 3, "2 M", (int64_t)1500*1000L, HN_DIVISOR_1000, 2 },
|
||||
{ 3, "0 G", (int64_t)1500*1000L, HN_DIVISOR_1000, 3 },
|
||||
{ 3, "2 G", (int64_t)1500*1000*1000L, HN_DIVISOR_1000, 3 },
|
||||
{ 3, "0 T", (int64_t)1500*1000*1000L, HN_DIVISOR_1000, 4 },
|
||||
{ 3, "2 T", (int64_t)1500*1000*1000*1000L, HN_DIVISOR_1000, 4 },
|
||||
{ 3, "0 P", (int64_t)1500*1000*1000*1000L, HN_DIVISOR_1000, 5 },
|
||||
{ 3, "2 P", (int64_t)1500*1000*1000*1000*1000L, HN_DIVISOR_1000, 5 },
|
||||
{ 3, "0 E", (int64_t)1500*1000*1000*1000*1000L, HN_DIVISOR_1000, 6 },
|
||||
{ 3, "2 E", (int64_t)1500*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, 6 },
|
||||
|
||||
/* tests 62-85 test specific scale factors with 1024 divisor */
|
||||
{ 3, "0 K", (int64_t)0L, 0, 1 },
|
||||
{ 3, "1 K", (int64_t)512L, 0, 1 },
|
||||
{ 3, "0 M", (int64_t)512L, 0, 2 },
|
||||
{ 3, "1 M", (int64_t)512*1024L, 0, 2 },
|
||||
{ 3, "0 G", (int64_t)512*1024L, 0, 3 },
|
||||
{ 3, "1 G", (int64_t)512*1024*1024L, 0, 3 },
|
||||
{ 3, "0 T", (int64_t)512*1024*1024L, 0, 4 },
|
||||
{ 3, "1 T", (int64_t)512*1024*1024*1024L, 0, 4 },
|
||||
{ 3, "0 P", (int64_t)512*1024*1024*1024L, 0, 5 },
|
||||
{ 3, "1 P", (int64_t)512*1024*1024*1024*1024L, 0, 5 },
|
||||
{ 3, "0 E", (int64_t)512*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "1 E", (int64_t)512*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "0 K", (int64_t)1L, 0, 1 },
|
||||
{ 3, "2 K", (int64_t)1536L, 0, 1 },
|
||||
{ 3, "0 M", (int64_t)1536L, 0, 2 },
|
||||
{ 3, "2 M", (int64_t)1536*1024L, 0, 2 },
|
||||
{ 3, "0 G", (int64_t)1536*1024L, 0, 3 },
|
||||
{ 3, "2 G", (int64_t)1536*1024*1024L, 0, 3 },
|
||||
{ 3, "0 T", (int64_t)1536*1024*1024L, 0, 4 },
|
||||
{ 3, "2 T", (int64_t)1536*1024*1024*1024L, 0, 4 },
|
||||
{ 3, "0 P", (int64_t)1536*1024*1024*1024L, 0, 5 },
|
||||
{ 3, "2 P", (int64_t)1536*1024*1024*1024*1024L, 0, 5 },
|
||||
{ 3, "0 E", (int64_t)1536*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "2 E", (int64_t)1536*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
|
||||
/* tests 86-99 test invalid specific scale values of < 0 or >= 7 with
|
||||
and without HN_DIVISOR_1000 set */
|
||||
/* all should return errors with new code; with old, the latter 3
|
||||
are instead processed as if having AUTOSCALE and/or GETSCALE set */
|
||||
{ -1, "", (int64_t)1L, 0, 7 },
|
||||
{ -1, "", (int64_t)1L, HN_DIVISOR_1000, 7 },
|
||||
{ -1, "", (int64_t)1L, 0, 1000 },
|
||||
{ -1, "", (int64_t)1L, HN_DIVISOR_1000, 1000 },
|
||||
{ -1, "", (int64_t)0L, 0, 1000*1000 },
|
||||
{ -1, "", (int64_t)0L, HN_DIVISOR_1000, 1000*1000 },
|
||||
{ -1, "", (int64_t)0L, 0, INT_MAX },
|
||||
{ -1, "", (int64_t)0L, HN_DIVISOR_1000, INT_MAX },
|
||||
|
||||
/* Negative scale values are not handled well
|
||||
by the existing library routine - should report as error */
|
||||
/* all should return errors with new code, fail assertion with old */
|
||||
|
||||
{ -1, "", (int64_t)1L, 0, -1 },
|
||||
{ -1, "", (int64_t)1L, HN_DIVISOR_1000, -1 },
|
||||
{ -1, "", (int64_t)1L, 0, -1000 },
|
||||
{ -1, "", (int64_t)1L, HN_DIVISOR_1000, -1000 },
|
||||
|
||||
/* __INT_MIN doesn't print properly, skipped. */
|
||||
|
||||
{ -1, "", (int64_t)1L, 0, -__INT_MAX },
|
||||
{ -1, "", (int64_t)1L, HN_DIVISOR_1000, -__INT_MAX },
|
||||
|
||||
|
||||
/* tests for scale == 0, without autoscale */
|
||||
/* tests 100-114 test scale 0 with 1000 divisor - print first N digits */
|
||||
{ 2, "0 ", (int64_t)0L, HN_DIVISOR_1000, 0 },
|
||||
{ 2, "1 ", (int64_t)1L, HN_DIVISOR_1000, 0 },
|
||||
{ 3, "10 ", (int64_t)10L, HN_DIVISOR_1000, 0 },
|
||||
{ 3, "0 M", (int64_t)150L, HN_DIVISOR_1000, HN_NOSPACE },
|
||||
{ 3, "0 M", (int64_t)500L, HN_DIVISOR_1000, HN_NOSPACE },
|
||||
{ 3, "0 M", (int64_t)999L, HN_DIVISOR_1000, HN_NOSPACE },
|
||||
{ 4, "150", (int64_t)150L, HN_DIVISOR_1000, 0 },
|
||||
{ 4, "500", (int64_t)500L, HN_DIVISOR_1000, 0 },
|
||||
{ 4, "999", (int64_t)999L, HN_DIVISOR_1000, 0 },
|
||||
{ 5, "100", (int64_t)1000L, HN_DIVISOR_1000, 0 },
|
||||
{ 5, "150", (int64_t)1500L, HN_DIVISOR_1000, 0 },
|
||||
{ 7, "500", (int64_t)500*1000L, HN_DIVISOR_1000, 0 },
|
||||
{ 8, "150", (int64_t)1500*1000L, HN_DIVISOR_1000, 0 },
|
||||
{ 10, "500", (int64_t)500*1000*1000L, HN_DIVISOR_1000, 0 },
|
||||
{ 11, "150", (int64_t)1500*1000*1000L, HN_DIVISOR_1000, 0 },
|
||||
|
||||
/* tests 115-126 test scale 0 with 1024 divisor - print first N digits */
|
||||
{ 2, "0 ", (int64_t)0L, 0, 0 },
|
||||
{ 2, "1 ", (int64_t)1L, 0, 0 },
|
||||
{ 3, "10 ", (int64_t)10L, 0, 0 },
|
||||
{ 4, "150", (int64_t)150L, 0, 0 },
|
||||
{ 4, "500", (int64_t)500L, 0, 0 },
|
||||
{ 4, "999", (int64_t)999L, 0, 0 },
|
||||
{ 5, "100", (int64_t)1000L, 0, 0 },
|
||||
{ 5, "150", (int64_t)1500L, 0, 0 },
|
||||
{ 7, "500", (int64_t)500*1000L, 0, 0 },
|
||||
{ 8, "150", (int64_t)1500*1000L, 0, 0 },
|
||||
{ 10, "500", (int64_t)500*1000*1000L, 0, 0 },
|
||||
{ 11, "150", (int64_t)1500*1000*1000L, 0, 0 },
|
||||
|
||||
/* Test boundary cases for very large positive/negative number formatting */
|
||||
/* Explicit scale, divisor 1024 */
|
||||
|
||||
/* XXX = requires length 5 (buflen 6) for some cases*/
|
||||
/* KLUDGE - test loop below will bump length 5 up to 5 */
|
||||
{ 3, "8 E", INT64_MAX, 0, 6 },
|
||||
{ 4, "-8 E", -INT64_MAX, 0, 6 },
|
||||
{ 3, "0 E", (int64_t)92*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "0 E", -(int64_t)92*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "0 E", (int64_t)82*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "0 E", -(int64_t)82*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "0 E", (int64_t)81*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 3, "0 E", -(int64_t)81*1024*1024*1024*1024*1024L, 0, 6 },
|
||||
{ 4, "92 P", (int64_t)92*1024*1024*1024*1024*1024L, 0, 5 },
|
||||
{ 5, "-92 P", -(int64_t)92*1024*1024*1024*1024*1024L, 0, 5 },
|
||||
{ 4, "82 P", (int64_t)82*1024*1024*1024*1024*1024L, 0, 5 },
|
||||
{ 5, "-82 P", -(int64_t)82*1024*1024*1024*1024*1024L, 0, 5 },
|
||||
{ 4, "81 P", (int64_t)81*1024*1024*1024*1024*1024L, 0, 5 },
|
||||
{ 5, "-81 P", -(int64_t)81*1024*1024*1024*1024*1024L, 0, 5 },
|
||||
|
||||
/* Explicit scale, divisor 1000 */
|
||||
{ 3, "9 E", INT64_MAX, HN_DIVISOR_1000, 6 },
|
||||
{ 4, "-9 E", -INT64_MAX, HN_DIVISOR_1000, 6 },
|
||||
{ 3, "0 E", (int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 6 },
|
||||
{ 3, "0 E", -(int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 6 },
|
||||
{ 3, "0 E", (int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 6 },
|
||||
{ 3, "0 E", -(int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 6 },
|
||||
{ 4, "92 P", (int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 5 },
|
||||
{ 5, "-92 P", -(int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 5 },
|
||||
{ 4, "91 P", (int64_t)81*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 5 },
|
||||
{ 5, "-91 P", -(int64_t)81*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 5 },
|
||||
|
||||
/* Autoscale, divisor 1024 */
|
||||
{ 3, "8 E", INT64_MAX, 0, HN_AUTOSCALE },
|
||||
{ 4, "-8 E", -INT64_MAX, 0, HN_AUTOSCALE },
|
||||
{ 4, "92 P", (int64_t)92*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 5, "-92 P", -(int64_t)92*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 4, "82 P", (int64_t)82*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 5, "-82 P", -(int64_t)82*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 4, "81 P", (int64_t)81*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
{ 5, "-81 P", -(int64_t)81*1024*1024*1024*1024*1024L, 0, HN_AUTOSCALE },
|
||||
/* Autoscale, divisor 1000 */
|
||||
{ 3, "9 E", INT64_MAX, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 4, "-9 E", -INT64_MAX, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 4, "92 P", (int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "-92 P", -(int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 4, "91 P", (int64_t)81*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "-91 P", -(int64_t)81*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
|
||||
/* 0 scale, divisor 1024 */
|
||||
{ 12, "skdj", INT64_MAX, 0, 0 },
|
||||
{ 21, "-9223", -INT64_MAX, 0, 0 },
|
||||
{ 19, "10358", (int64_t)92*1024*1024*1024*1024*1024L, 0, 0 },
|
||||
{ 20, "-1035", -(int64_t)92*1024*1024*1024*1024*1024L, 0, 0 },
|
||||
{ 18, "92323", (int64_t)82*1024*1024*1024*1024*1024L, 0, 0 },
|
||||
{ 19, "-9232", -(int64_t)82*1024*1024*1024*1024*1024L, 0, 0 },
|
||||
{ 18, "91197", (int64_t)81*1024*1024*1024*1024*1024L, 0, 0 },
|
||||
{ 19, "-9119", -(int64_t)81*1024*1024*1024*1024*1024L, 0, 0 },
|
||||
|
||||
/* 0 scale, divisor 1000 */
|
||||
/* XXX - why does this fail? */
|
||||
{ -1, "", INT64_MAX, HN_DIVISOR_1000, 0 },
|
||||
{ 21, "-9223", -INT64_MAX, HN_DIVISOR_1000, 0 },
|
||||
{ 19, "10358", (int64_t)92*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 0 },
|
||||
{ 20, "-1035", -(int64_t)92*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 0 },
|
||||
{ 18, "92323", (int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 0 },
|
||||
{ 19, "-9232", -(int64_t)82*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 0 },
|
||||
/* Expected to pass */
|
||||
{ 18, "91197", (int64_t)81*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 0 },
|
||||
{ 19, "-9119", -(int64_t)81*1024*1024*1024*1024*1024L, HN_DIVISOR_1000, 0 },
|
||||
|
||||
|
||||
|
||||
/* Need to implement tests for GETSCALE */
|
||||
/* { ?, "", (int64_t)0L, HN_DIVISOR_1000, HN_GETSCALE },
|
||||
...
|
||||
*/
|
||||
/* Tests for HN_DECIMAL */
|
||||
/* Positive, Autoscale */
|
||||
{ 5, "500 k", (int64_t)500*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "994 k", (int64_t)994*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "995 k", (int64_t)995*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "999 k", (int64_t)999*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "1.0 M", (int64_t)1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "1.5 M", (int64_t)1500*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "1.9 M", (int64_t)1949*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "2.0 M", (int64_t)1950*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "9.9 M", (int64_t)9949*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 4, "10 M", (int64_t)9950*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "500 M", (int64_t)500*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "994 M", (int64_t)994*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "995 M", (int64_t)995*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "999 M", (int64_t)999*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
|
||||
{ 5, "500 K", (int64_t)500*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "994 K", (int64_t)994*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "995 K", (int64_t)995*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "999 K", (int64_t)999*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "1.0 M", (int64_t)1000*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "1.0 M", (int64_t)1018*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "1.0 M", (int64_t)1019*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "1.5 M", (int64_t)1536*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "1.9 M", (int64_t)1996*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "2.0 M", (int64_t)1997*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "2.0 M", (int64_t)2047*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "2.0 M", (int64_t)2048*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "2.0 M", (int64_t)2099*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "2.1 M", (int64_t)2100*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "9.9 M", (int64_t)10188*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
/* XXX - shouldn't the following two be "10. M"? */
|
||||
{ 4, "10 M", (int64_t)10189*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 4, "10 M", (int64_t)10240*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "500 M", (int64_t)500*1024*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "994 M", (int64_t)994*1024*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "995 M", (int64_t)995*1024*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "999 M", (int64_t)999*1024*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "1.0 G", (int64_t)1000*1024*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "1.0 G", (int64_t)1023*1024*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
|
||||
/* Negative, Autoscale - should pass */
|
||||
{ 6, "-1.5 ", -(int64_t)1500*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 6, "-1.9 ", -(int64_t)1949*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 6, "-9.9 ", -(int64_t)9949*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
|
||||
{ 6, "-1.5 ", -(int64_t)1536*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 6, "-1.9 ", -(int64_t)1949*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 6, "-9.7 ", -(int64_t)9949*1024L, HN_DECIMAL, HN_AUTOSCALE },
|
||||
|
||||
/* Positive/negative, at maximum scale */
|
||||
{ 5, "500 P", (int64_t)500*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "1.9 E", (int64_t)1949*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "8.9 E", (int64_t)8949*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 5, "9.2 E", INT64_MAX, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
/* Negatives work with latest rev only: */
|
||||
{ 6, "-9.2 ", -INT64_MAX, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
{ 6, "-8.9 ", -(int64_t)8949*1000*1000*1000*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, HN_AUTOSCALE },
|
||||
|
||||
{ 5, "8.0 E", INT64_MAX, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 5, "7.9 E", INT64_MAX-(int64_t)100*1024*1024*1024*1024*1024LL, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 6, "-8.0 ", -INT64_MAX, HN_DECIMAL, HN_AUTOSCALE },
|
||||
{ 6, "-7.9 ", -INT64_MAX+(int64_t)100*1024*1024*1024*1024*1024LL, HN_DECIMAL, HN_AUTOSCALE },
|
||||
|
||||
/* Positive, Fixed scales */
|
||||
{ 5, "500 k", (int64_t)500*1000L, HN_DECIMAL|HN_DIVISOR_1000, 1 },
|
||||
{ 5, "0.5 M", (int64_t)500*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "949 k", (int64_t)949*1000L, HN_DECIMAL|HN_DIVISOR_1000, 1 },
|
||||
{ 5, "0.9 M", (int64_t)949*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "950 k", (int64_t)950*1000L, HN_DECIMAL|HN_DIVISOR_1000, 1 },
|
||||
{ 5, "1.0 M", (int64_t)950*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "999 k", (int64_t)999*1000L, HN_DECIMAL|HN_DIVISOR_1000, 1 },
|
||||
{ 5, "1.0 M", (int64_t)999*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "1.5 M", (int64_t)1500*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "1.9 M", (int64_t)1949*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "2.0 M", (int64_t)1950*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "9.9 M", (int64_t)9949*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 4, "10 M", (int64_t)9950*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "500 M", (int64_t)500*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "0.5 G", (int64_t)500*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, 3 },
|
||||
{ 5, "999 M", (int64_t)999*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, 2 },
|
||||
{ 5, "1.0 G", (int64_t)999*1000*1000L, HN_DECIMAL|HN_DIVISOR_1000, 3 },
|
||||
/* Positive/negative, at maximum scale */
|
||||
{ 5, "500 P", (int64_t)500*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, 5 },
|
||||
{ 5, "1.0 E", (int64_t)500*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, 6 },
|
||||
{ 5, "1.9 E", (int64_t)1949*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, 6 },
|
||||
{ 5, "8.9 E", (int64_t)8949*1000*1000*1000*1000*1000L, HN_DIVISOR_1000, 6 },
|
||||
{ 5, "9.2 E", INT64_MAX, HN_DECIMAL|HN_DIVISOR_1000, 6 },
|
||||
|
||||
/* HN_DECIMAL + binary + fixed scale cases not completed */
|
||||
{ 5, "512 K", (int64_t)512*1024L, HN_DECIMAL, 1 },
|
||||
{ 5, "0.5 M", (int64_t)512*1024L, HN_DECIMAL, 2 },
|
||||
|
||||
/* Negative, Fixed scales */
|
||||
/* Not yet added, but should work with latest rev */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Command line options usage */
|
||||
static void
|
||||
usage(char * progname) {
|
||||
printf("%s: tests libutil humanize_number function\n", progname);
|
||||
printf("Usage: %s [-nE] [-l num] [-v]\n\n", progname);
|
||||
printf("Options:\n");
|
||||
printf("\t-l num\tSet max length for result; buflen = num + 1\n");
|
||||
printf("\t\t (NOTE: does not change expected result strings.)\n");
|
||||
printf("\t-n\tInclude negative scale tests, which cause older libutil\n");
|
||||
printf("\t\t version of function to coredump with assertion failure\n");
|
||||
printf("\t-E\tInclude numbers > 1/2 Exa[byte] which currently fail\n");
|
||||
printf("\t-v\tVerbose - always print summary results\n");
|
||||
printf("\t-h, -?\tShow options\n");
|
||||
}
|
||||
|
||||
/* Parse command line options */
|
||||
static void
|
||||
read_options(int argc, char * const argv[], size_t *bufLength,
|
||||
int *includeNegativeScale, int *includeExabytes, int *verbose) {
|
||||
int ch;
|
||||
size_t temp;
|
||||
|
||||
while ((ch = getopt(argc, argv, "nEh?vl:")) != -1) {
|
||||
switch (ch) {
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
break; /* UNREACHABLE */
|
||||
case 'h' :
|
||||
case '?' :
|
||||
usage(argv[0]);
|
||||
exit(0);
|
||||
break; /* UNREACHABLE */
|
||||
case 'l' :
|
||||
sscanf(optarg, "%zu", &temp);
|
||||
*bufLength = temp + 1;
|
||||
break;
|
||||
case 'n' :
|
||||
*includeNegativeScale = 1;
|
||||
break;
|
||||
case 'E' :
|
||||
*includeExabytes = 1;
|
||||
break;
|
||||
case 'v' :
|
||||
*verbose = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct {
|
||||
int value;
|
||||
const char *name;
|
||||
} flags[] = {
|
||||
{ HN_AUTOSCALE, "HN_AUTOSCALE" },
|
||||
{ HN_GETSCALE, "HN_GETSCALE" },
|
||||
{ HN_DIVISOR_1000, "HN_DIVISOR_1000"},
|
||||
{ HN_B, "HN_B"},
|
||||
{ HN_DECIMAL, "HN_DECIMAL"},
|
||||
};
|
||||
|
||||
static const char *separator = "|";
|
||||
|
||||
/* Format flags parameter for meaningful display */
|
||||
static char *
|
||||
str_flags(int hn_flags, char *noFlags) {
|
||||
size_t i;
|
||||
char * result;
|
||||
|
||||
result = malloc(MAX_STR_FLAGS_RESULT);
|
||||
result[0] = '\0';
|
||||
|
||||
for (i = 0; i < sizeof flags / sizeof *flags; i++) {
|
||||
if (hn_flags & flags[i].value) {
|
||||
if (*result != 0)
|
||||
strlcat(result, separator,
|
||||
MAX_STR_FLAGS_RESULT);
|
||||
strlcat(result, flags[i].name, MAX_STR_FLAGS_RESULT);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(result) == 0)
|
||||
strlcat(result, noFlags, MAX_STR_FLAGS_RESULT);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Format scale parameter for meaningful display */
|
||||
static char *
|
||||
str_scale(int scale) {
|
||||
char *result;
|
||||
|
||||
if (scale == HN_AUTOSCALE || scale == HN_GETSCALE)
|
||||
return str_flags(scale, "");
|
||||
|
||||
result = malloc(MAX_INT_STR_DIGITS);
|
||||
result[0] = '\0';
|
||||
snprintf(result, MAX_INT_STR_DIGITS, "%d", scale);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
testskipped(size_t i)
|
||||
{
|
||||
|
||||
printf("ok %lu # skip - not turned on\n", i);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char * const argv[])
|
||||
{
|
||||
char *buf;
|
||||
char *flag_str, *scale_str;
|
||||
size_t i;
|
||||
size_t errcnt, tested, skipped;
|
||||
int r;
|
||||
size_t buflen;
|
||||
int includeNegScale;
|
||||
int includeExabyteTests;
|
||||
int verbose;
|
||||
|
||||
buflen = 4;
|
||||
includeNegScale = 0;
|
||||
includeExabyteTests = 0;
|
||||
verbose = 0;
|
||||
|
||||
read_options(argc, argv, &buflen, &includeNegScale,
|
||||
&includeExabyteTests, &verbose);
|
||||
|
||||
buf = malloc(buflen);
|
||||
errcnt = 0;
|
||||
tested = 0;
|
||||
skipped = 0;
|
||||
|
||||
if (buflen != 4)
|
||||
printf("Warning: buffer size %zu != 4, expect some results to differ.\n", buflen);
|
||||
|
||||
printf("1..%lu\n", sizeof test_args / sizeof *test_args);
|
||||
for (i = 0; i < sizeof test_args / sizeof *test_args; i++) {
|
||||
/* KLUDGE */
|
||||
if (test_args[i].num == INT64_MAX && buflen == 4) {
|
||||
/* Start final tests which require buffer of 6 */
|
||||
free(buf);
|
||||
buflen = 6;
|
||||
buf = malloc(buflen);
|
||||
if (verbose)
|
||||
printf("Buffer length increased to %zu\n",
|
||||
buflen);
|
||||
}
|
||||
|
||||
if (test_args[i].scale < 0 && ! includeNegScale) {
|
||||
skipped++;
|
||||
testskipped(i);
|
||||
continue;
|
||||
}
|
||||
if (test_args[i].num >= halfExabyte && ! includeExabyteTests) {
|
||||
skipped++;
|
||||
testskipped(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
r = humanize_number(buf, buflen, test_args[i].num, "",
|
||||
test_args[i].scale, test_args[i].flags);
|
||||
flag_str = str_flags(test_args[i].flags, "[no flags]");
|
||||
scale_str = str_scale(test_args[i].scale);
|
||||
|
||||
if (r != test_args[i].retval) {
|
||||
if (verbose)
|
||||
printf("wrong return value on index %lu, buflen: %zu, got: %d + \"%s\", expected %d + \"%s\"; num = %" PRId64 ", scale = %s, flags= %s.\n",
|
||||
i, buflen, r, buf, test_args[i].retval,
|
||||
test_args[i].res, test_args[i].num,
|
||||
scale_str, flag_str);
|
||||
else
|
||||
printf("not ok %lu # return %d != %d\n", i, r,
|
||||
test_args[i].retval);
|
||||
errcnt++;
|
||||
} else if (strcmp(buf, test_args[i].res) != 0) {
|
||||
if (verbose)
|
||||
printf("result mismatch on index %lu, got: \"%s\", expected \"%s\"; num = %" PRId64 ", scale = %s, flags= %s.\n",
|
||||
i, buf, test_args[i].res, test_args[i].num,
|
||||
scale_str, flag_str);
|
||||
else
|
||||
printf("not ok %lu # buf \"%s\" != \"%s\"\n", i,
|
||||
buf, test_args[i].res);
|
||||
errcnt++;
|
||||
} else {
|
||||
if (verbose)
|
||||
printf("successful result on index %lu, returned %d, got: \"%s\"; num = %" PRId64 ", scale = %s, flags= %s.\n",
|
||||
i, r, buf, test_args[i].num, scale_str,
|
||||
flag_str);
|
||||
else
|
||||
printf("ok %lu\n", i);
|
||||
}
|
||||
tested++;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
printf("total errors: %lu/%lu tests, %lu skipped\n", errcnt,
|
||||
tested, skipped);
|
||||
|
||||
if (errcnt)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
10
tools/regression/lib/libutil/test-humanize_number.t
Executable file
10
tools/regression/lib/libutil/test-humanize_number.t
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
cd `dirname $0`
|
||||
|
||||
executable=`basename $0 .t`
|
||||
|
||||
make $executable 2>&1 > /dev/null
|
||||
|
||||
exec ./$executable && echo humanize_numbers ok
|
@ -1655,10 +1655,15 @@ ktrstat(struct stat *statp)
|
||||
* buffer exactly sizeof(struct stat) bytes long.
|
||||
*/
|
||||
printf("struct stat {");
|
||||
strmode(statp->st_mode, mode);
|
||||
printf("dev=%ju, ino=%ju, mode=%s, nlink=%ju, ",
|
||||
(uintmax_t)statp->st_dev, (uintmax_t)statp->st_ino, mode,
|
||||
(uintmax_t)statp->st_nlink);
|
||||
printf("dev=%ju, ino=%ju, ",
|
||||
(uintmax_t)statp->st_dev, (uintmax_t)statp->st_ino);
|
||||
if (resolv == 0)
|
||||
printf("mode=0%jo, ", (uintmax_t)statp->st_mode);
|
||||
else {
|
||||
strmode(statp->st_mode, mode);
|
||||
printf("mode=%s, ", mode);
|
||||
}
|
||||
printf("nlink=%ju, ", (uintmax_t)statp->st_nlink);
|
||||
if (resolv == 0 || (pwd = getpwuid(statp->st_uid)) == NULL)
|
||||
printf("uid=%ju, ", (uintmax_t)statp->st_uid);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user