Merge ^/head r352587 through r352763.

This commit is contained in:
Dimitry Andric 2019-09-26 18:25:54 +00:00
commit 668ee10168
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang900-import/; revision=352764
251 changed files with 24623 additions and 3355 deletions

View File

@ -947,7 +947,8 @@ _cleanobj_fast_depend_hack: .PHONY
# Syscall stubs rewritten in C and obsolete MD assembly implementations
# Date SVN Rev Syscalls
# 20180604 r334626 brk sbrk
.for f in brk sbrk
# 20190916 r352703 shm_open
.for f in brk sbrk shm_open
@if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
egrep -qw '${f}\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
echo "Removing stale dependencies for ${f} syscall wrappers"; \

View File

@ -827,6 +827,9 @@ OLD_DIRS+=usr/lib/clang/6.0.1/lib
OLD_DIRS+=usr/lib/clang/6.0.1
# 20181116: Rename test file.
OLD_FILES+=usr/tests/sys/netinet/reuseport_lb
# 20181113: libufs version bumped to 7.
OLD_LIBS+=lib/libufs.so.6
OLD_LIBS+=usr/lib32/libufs.so.6
# 20181112: Cleanup old libcap_dns.
OLD_LIBS+=lib/casper/libcap_dns.so.1
OLD_LIBS+=usr/lib32/libcap_dns.so.1

View File

@ -10,6 +10,11 @@ newline. Entries should be separated by a newline.
Changes to this file should not be MFCed.
r352668:
cron(8) now supports the -n (suppress mail on succesful run) and -q
(suppress logging of command execution) options in the crontab format.
See the crontab(5) manpage for details.
r352304:
ntpd is no longer by default locked in memory. rlimit memlock 32
or rlimit memlock 0 can be used to restore this behaviour.

View File

@ -948,39 +948,32 @@ typedef struct send_dump_data {
} send_dump_data_t;
static int
estimate_ioctl(zfs_handle_t *zhp, uint64_t fromsnap_obj,
boolean_t fromorigin, enum lzc_send_flags flags, uint64_t *sizep)
zfs_send_space(zfs_handle_t *zhp, const char *snapname, const char *from,
enum lzc_send_flags flags, uint64_t *spacep)
{
zfs_cmd_t zc = { 0 };
libzfs_handle_t *hdl = zhp->zfs_hdl;
int error;
assert(zhp->zfs_type == ZFS_TYPE_SNAPSHOT);
assert(fromsnap_obj == 0 || !fromorigin);
assert(snapname != NULL);
error = lzc_send_space(snapname, from, flags, spacep);
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
zc.zc_obj = fromorigin;
zc.zc_sendobj = zfs_prop_get_int(zhp, ZFS_PROP_OBJSETID);
zc.zc_fromobj = fromsnap_obj;
zc.zc_guid = 1; /* estimate flag */
zc.zc_flags = flags;
if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_SEND, &zc) != 0) {
if (error != 0) {
char errbuf[1024];
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"warning: cannot estimate space for '%s'"), zhp->zfs_name);
"warning: cannot estimate space for '%s'"), snapname);
switch (errno) {
switch (error) {
case EXDEV:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"not an earlier snapshot from the same fs"));
return (zfs_error(hdl, EZFS_CROSSTARGET, errbuf));
case ENOENT:
if (zfs_dataset_exists(hdl, zc.zc_name,
if (zfs_dataset_exists(hdl, snapname,
ZFS_TYPE_SNAPSHOT)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"incremental source (@%s) does not exist"),
zc.zc_value);
"incremental source (%s) does not exist"),
snapname);
}
return (zfs_error(hdl, EZFS_NOENT, errbuf));
@ -994,16 +987,15 @@ estimate_ioctl(zfs_handle_t *zhp, uint64_t fromsnap_obj,
case ERANGE:
case EFAULT:
case EROFS:
zfs_error_aux(hdl, strerror(errno));
case EINVAL:
zfs_error_aux(hdl, strerror(error));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
default:
return (zfs_standard_error(hdl, errno, errbuf));
return (zfs_standard_error(hdl, error, errbuf));
}
}
*sizep = zc.zc_objset_type;
return (0);
}
@ -1290,13 +1282,22 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
(sdd->fromorigin || sdd->replicate);
if (sdd->verbose || sdd->progress) {
(void) estimate_ioctl(zhp, sdd->prevsnap_obj,
fromorigin, flags, &size);
sdd->size += size;
char fromds[ZFS_MAX_DATASET_NAME_LEN];
send_print_verbose(fout, zhp->zfs_name,
sdd->prevsnap[0] ? sdd->prevsnap : NULL,
size, sdd->parsable);
if (sdd->prevsnap[0] != '\0') {
(void) strlcpy(fromds, zhp->zfs_name, sizeof (fromds));
*(strchr(fromds, '@') + 1) = '\0';
(void) strlcat(fromds, sdd->prevsnap, sizeof (fromds));
}
if (zfs_send_space(zhp, zhp->zfs_name,
sdd->prevsnap[0] ? fromds : NULL, flags, &size) != 0) {
size = 0; /* cannot estimate send space */
} else {
send_print_verbose(fout, zhp->zfs_name,
sdd->prevsnap[0] ? sdd->prevsnap : NULL,
size, sdd->parsable);
}
sdd->size += size;
}
if (!sdd->dryrun) {
@ -2054,6 +2055,15 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t flags)
if (err == 0) {
send_print_verbose(fout, zhp->zfs_name, from, size,
flags.parsable);
if (flags.parsable) {
(void) fprintf(fout, "size\t%llu\n",
(longlong_t)size);
} else {
char buf[16];
zfs_nicenum(size, buf, sizeof (buf));
(void) fprintf(fout, dgettext(TEXT_DOMAIN,
"total estimated size is %s\n"), buf);
}
} else {
(void) fprintf(stderr, "Cannot estimate send size: "
"%s\n", strerror(errno));

View File

@ -309,11 +309,27 @@ range: addrmask { $$ = calloc(1, sizeof(*$$));
$$->ipn_info = 0;
$$->ipn_addr = $1[0];
$$->ipn_mask = $1[1];
#ifdef USE_INET6
if (use_inet6)
$$->ipn_addr.adf_family =
AF_INET6;
else
#endif
$$->ipn_addr.adf_family =
AF_INET;
}
| '!' addrmask { $$ = calloc(1, sizeof(*$$));
$$->ipn_info = 1;
$$->ipn_addr = $2[0];
$$->ipn_mask = $2[1];
#ifdef USE_INET6
if (use_inet6)
$$->ipn_addr.adf_family =
AF_INET6;
else
#endif
$$->ipn_addr.adf_family =
AF_INET;
}
| YY_STR { $$ = add_poolhosts($1);
free($1);

View File

@ -34,16 +34,15 @@
.Nm
.Op options
.Op files
.Pp
.Sh DESCRIPTION
.Nm
expands files to standard output.
.Sh OPTIONS
.Nm
typically takes a filename as an argument or reads standard input when used in a
pipe. In both cases decompressed data it written to standard output.
pipe.
In both cases decompressed data it written to standard output.
.Sh EXAMPLES
.Pp
To decompress a file:
.Pp
.Dl bsdcat example.txt.gz > example.txt
@ -55,8 +54,8 @@ To decompress standard input in a pipe:
Both examples achieve the same results - a decompressed file by redirecting
output.
.Sh SEE ALSO
.Xr uncompress 1 ,
.Xr zcat 1 ,
.Xr bzcat 1 ,
.Xr uncompress 1 ,
.Xr xzcat 1 ,
.Xr libarchive-formats 5 ,
.Xr zcat 1 ,
.Xr libarchive-formats 5

View File

@ -75,7 +75,6 @@ Pass-through.
Read a list of filenames from standard input and copy the files to the
specified directory.
.El
.Pp
.Sh OPTIONS
Unless specifically stated otherwise, options are applicable in
all operating modes.
@ -385,10 +384,10 @@ For best compatibility, scripts should limit themselves to the
standard syntax.
.Sh SEE ALSO
.Xr bzip2 1 ,
.Xr tar 1 ,
.Xr gzip 1 ,
.Xr mt 1 ,
.Xr pax 1 ,
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr libarchive-formats 5 ,

View File

@ -52,7 +52,7 @@
*/
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
# include <stdint.h>
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__)
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) && !defined(__CLANG_INTTYPES_H)
# include <inttypes.h>
#endif

View File

@ -32,7 +32,7 @@
.Nm archive_entry_clear ,
.Nm archive_entry_clone ,
.Nm archive_entry_free ,
.Nm archive_entry_new ,
.Nm archive_entry_new
.Nd functions for managing archive entry descriptions
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@ -126,7 +126,6 @@ using the current locale.
Similarly, if you store a wide string and then store a
narrow string for the same data, the previously-set wide string will
be discarded in favor of the new data.
.Pp
.\" .Sh EXAMPLE
.\" .Sh RETURN VALUES
.\" .Sh ERRORS
@ -134,8 +133,8 @@ be discarded in favor of the new data.
.Xr archive_entry_acl 3 ,
.Xr archive_entry_paths 3 ,
.Xr archive_entry_perms 3 ,
.Xr archive_entry_time 3
.Xr libarchive 3 ,
.Xr archive_entry_time 3 ,
.Xr libarchive 3
.Sh HISTORY
The
.Nm libarchive

View File

@ -118,15 +118,16 @@ Streaming Archive Library (libarchive, -larchive)
.Sh DESCRIPTION
The
.Dq Access Control Lists (ACLs)
extend the standard Unix perssion model.
extend the standard Unix permission model.
The ACL interface of
.Nm libarchive
supports both POSIX.1e and NFSv4 style ACLs. Use of ACLs is restricted by
supports both POSIX.1e and NFSv4 style ACLs.
Use of ACLs is restricted by
various levels of ACL support in operating systems, file systems and archive
formats.
.Ss POSIX.1e Access Control Lists
A POSIX.1e ACL consists of a number of independent entries.
Each entry specifies the permission set as bitmask of basic permissions.
Each entry specifies the permission set as a bitmask of basic permissions.
Valid permissions in the
.Fa permset
are:
@ -147,13 +148,13 @@ The user specified by the name field.
.It Dv ARCHIVE_ENTRY_ACL_USER_OBJ
The owner of the file.
.It Dv ARCHIVE_ENTRY_ACL_GROUP
The group specied by the name field.
The group specified by the name field.
.It Dv ARCHIVE_ENTRY_ACL_GROUP_OBJ
The group who owns the file.
The group which owns the file.
.It Dv ARCHIVE_ENTRY_ACL_MASK
The maximum permissions to be obtained via group permissions.
.It Dv ARCHIVE_ENTRY_ACL_OTHER
Any principal who is not file owner or a member of the owning group.
Any principal who is not the file owner or a member of the owning group.
.El
.Pp
The principals
@ -164,12 +165,12 @@ and
are equivalent to user, group and other in the classic Unix permission
model and specify non-extended ACL entries.
.Pp
All files with have an access ACL
All files have an access ACL
.Pq Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS .
This specifies the permissions required for access to the file itself.
Directories have an additional ACL
.Pq Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT ,
which controls the initial access ACL for newly created directory entries.
which controls the initial access ACL for newly-created directory entries.
.Ss NFSv4 Access Control Lists
A NFSv4 ACL consists of multiple individual entries called Access Control
Entries (ACEs).
@ -197,11 +198,11 @@ The user specified by the name field.
.It Dv ARCHIVE_ENTRY_ACL_USER_OBJ
The owner of the file.
.It Dv ARCHIVE_ENTRY_ACL_GROUP
The group specied by the name field.
The group specified by the name field.
.It Dv ARCHIVE_ENTRY_ACL_GROUP_OBJ
The group who owns the file.
The group which owns the file.
.It Dv ARCHIVE_ENTRY_ACL_EVERYONE
Any principal who is not file owner or a member of the owning group.
Any principal who is not the file owner or a member of the owning group.
.El
.Pp
Entries with the
@ -216,9 +217,10 @@ integer.
.Pp
NFSv4 ACE permissions and flags are stored in the same
.Fa permset
bitfield. Some permissions share the same constant and permission character but
have different effect on directories than on files. The following ACE
permissions are supported:
bitfield.
Some permissions share the same constant and permission character
but have different effect on directories than on files.
The following ACE permissions are supported:
.Bl -tag -offset indent -compact -width ARCHIV
.It Dv ARCHIVE_ENTRY_ACL_READ_DATA ( Sy r )
Read data (file).
@ -265,7 +267,8 @@ Inherit parent directory ACE to subdirectories.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY ( Sy i )
Only inherit, do not apply the permission on the directory itself.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT ( Sy n )
Do not propagate inherit flags. Only first-level entries inherit ACLs.
Do not propagate inherit flags.
Only first-level entries inherit ACLs.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS ( Sy S )
Trigger alarm or audit on successful access.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS ( Sy F )
@ -279,8 +282,8 @@ and
.Fn archive_entry_acl_add_entry_w
add a single ACL entry.
For the access ACL and non-extended principals, the classic Unix permissions
are updated. An archive entry cannot contain both POSIX.1e and NFSv4 ACL
entries.
are updated.
An archive entry cannot contain both POSIX.1e and NFSv4 ACL entries.
.Pp
.Fn archive_entry_acl_clear
removes all ACL entries and resets the enumeration pointer.
@ -300,7 +303,8 @@ for POSIX.1e ACLs and
.It Dv ARCHIVE_ENTRY_ACL_TYPE_AUDIT
.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALARM
.El
for NFSv4 ACLs. For POSIX.1e ACLs if
for NFSv4 ACLs.
For POSIX.1e ACLs if
.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
is included and at least one extended ACL entry is found,
the three non-extended ACLs are added.
@ -312,7 +316,8 @@ add new
.Pq or merge with existing
ACL entries from
.Pq wide
text. The argument
text.
The argument
.Fa type
may take one of the following values:
.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYPE_DEFAULT"
@ -322,11 +327,13 @@ may take one of the following values:
.El
Supports all formats that can be created with
.Fn archive_entry_acl_to_text
or respective
or respectively
.Fn archive_entry_acl_to_text_w .
Existing ACL entries are preserved. To get a clean new ACL from text
Existing ACL entries are preserved.
To get a clean new ACL from text
.Fn archive_entry_acl_clear
must be called first. Entries prefixed with
must be called first.
Entries prefixed with
.Dq default:
are treated as
.Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT
@ -354,7 +361,7 @@ prepare reading the list of ACL entries with
.Fn archive_entry_acl_next
or
.Fn archive_entry_acl_next_w .
The function returns either 0, if no non-extended ACLs are found.
The function returns 0 if no non-extended ACLs are found.
In this case, the access permissions should be obtained by
.Xr archive_entry_mode 3
or set using
@ -367,7 +374,8 @@ and
.Fn archive_entry_acl_to_text_w
convert the ACL entries for the given type into a
.Pq wide
string of ACL entries separated by newline. If the pointer
string of ACL entries separated by newline.
If the pointer
.Fa len_p
is not NULL, then the function shall return the length of the string
.Pq not including the NULL terminator
@ -415,7 +423,8 @@ are prefixed with
.Dq default: .
.Pp
.Fn archive_entry_acl_types
get ACL entry types contained in an archive entry's ACL. As POSIX.1e and NFSv4
get ACL entry types contained in an archive entry's ACL.
As POSIX.1e and NFSv4
ACL entries cannot be mixed, this function is a very efficient way to detect if
an ACL already contains POSIX.1e or NFSv4 ACL entries.
.Sh RETURN VALUES

View File

@ -28,7 +28,7 @@
.Sh NAME
.Nm archive_entry_symlink_type ,
.Nm archive_entry_set_symlink_type
.Nd miscellaneous functions for manipulating properties of archive_entry.
.Nd miscellaneous functions for manipulating properties of archive_entry
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
.Sh SYNOPSIS
@ -42,7 +42,8 @@ The function
.Fn archive_entry_symlink_type
returns and the function
.Fn archive_entry_set_symlink_type
sets the type of the symbolic link stored in an archive entry. These functions
sets the type of the symbolic link stored in an archive entry.
These functions
have special meaning on operating systems that support multiple symbolic link
types (e.g. Microsoft Windows).
.Pp

View File

@ -133,7 +133,7 @@ The accessor functions are named
.Fn XXX_w .
.It UTF-8
Unicode strings encoded as UTF-8.
This are convience functions to update both the multibyte and wide
These are convenience functions to update both the multibyte and wide
character strings at the same time.
.El
.Pp
@ -141,13 +141,13 @@ The sourcepath is a pure filesystem concept and never stored in an
archive directly.
.Pp
For that reason, it is only available as multibyte string.
The link path is a convience function for conditionally setting
The link path is a convenience function for conditionally setting
hardlink or symlink destination.
It doesn't have a corresponding get accessor function.
.Pp
.Fn archive_entry_set_XXX
is an alias for
is an alias for
.Fn archive_entry_copy_XXX .
.Sh SEE ALSO
.Xr archive_entry 3
.Xr libarchive 3 ,
.Xr archive_entry 3 ,
.Xr libarchive 3

View File

@ -126,7 +126,7 @@ The corresponding functions
and
.Fn archive_entry_set_perm
store the given user id, group id and permission in the entry.
The permission is also set as side effect of calling
The permission is also set as a side effect of calling
.Fn archive_entry_set_mode .
.Pp
.Fn archive_entry_strmode
@ -143,12 +143,12 @@ The accessor functions are named
.Fn XXX_w .
.It UTF-8
Unicode strings encoded as UTF-8.
This are convience functions to update both the multibyte and wide
These are convenience functions to update both the multibyte and wide
character strings at the same time.
.El
.Pp
.Fn archive_entry_set_XXX
is an alias for
is an alias for
.Fn archive_entry_copy_XXX .
.Ss File Flags
File flags are transparently converted between a bitmap
@ -182,7 +182,7 @@ The
.Fn archive_entry_copy_fflags_text
and
.Fn archive_entry_copy_fflags_text_w
functions parse the provided text and sets the internal bitmap values.
functions parse the provided text and set the internal bitmap values.
This is a platform-specific operation; names that are not meaningful
on the current platform will be ignored.
The function returns a pointer to the start of the first name that was not
@ -197,8 +197,8 @@ which stops parsing at the first unrecognized name.)
.Xr archive_entry 3 ,
.Xr archive_entry_acl 3 ,
.Xr archive_read_disk 3 ,
.Xr archive_write_disk 3
.Xr libarchive 3 ,
.Xr archive_write_disk 3 ,
.Xr libarchive 3
.Sh BUGS
The platform types
.Vt uid_t

View File

@ -54,7 +54,7 @@
.Nm archive_entry_rdevmajor ,
.Nm archive_entry_set_rdevmajor ,
.Nm archive_entry_rdevminor ,
.Nm archive_entry_set_rdevminor ,
.Nm archive_entry_set_rdevminor
.Nd accessor functions for manipulating archive entry descriptions
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@ -267,8 +267,8 @@ platforms.
Some archive formats use the combined form, while other formats use
the split form.
.Sh SEE ALSO
.Xr stat 2 ,
.Xr archive_entry_acl 3 ,
.Xr archive_entry_perms 3 ,
.Xr archive_entry_time 3 ,
.Xr libarchive 3 ,
.Xr stat 2
.Xr libarchive 3

View File

@ -48,7 +48,7 @@
.Nm archive_entry_mtime_nsec ,
.Nm archive_entry_mtime_is_set ,
.Nm archive_entry_set_mtime ,
.Nm archive_entry_unset_mtime ,
.Nm archive_entry_unset_mtime
.Nd functions for manipulating times in archive entry descriptions
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@ -113,8 +113,8 @@ The current state can be queried using
.Fn XXX_is_set .
Unset time fields have a second and nanosecond field of 0.
.Sh SEE ALSO
.Xr archive_entry 3
.Xr libarchive 3 ,
.Xr archive_entry 3 ,
.Xr libarchive 3
.Sh HISTORY
The
.Nm libarchive

View File

@ -155,7 +155,7 @@ to close the archive, then call
.Fn archive_read_free
to release all resources, including all memory allocated by the library.
.\"
.Sh EXAMPLE
.Sh EXAMPLES
The following illustrates basic usage of the library.
In this example,
the callback functions are simply wrappers around the standard
@ -217,16 +217,16 @@ myclose(struct archive *a, void *client_data)
.\" .Sh ERRORS
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read_new 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_extract 3 ,
.Xr archive_read_filter 3 ,
.Xr archive_read_format 3 ,
.Xr archive_read_header 3 ,
.Xr archive_read_new 3 ,
.Xr archive_read_open 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr libarchive 3 ,
.Xr tar 5
.Sh HISTORY
The

View File

@ -59,16 +59,16 @@ or empty, this function will do nothing and
will be returned.
Otherwise,
.Cm ARCHIVE_OK
will be returned.
will be returned.
.It Fn archive_read_set_passphrase_callback
Register callback function that will be invoked to get a passphrase
for decrption after trying all passphrases registered by the
Register a callback function that will be invoked to get a passphrase
for decryption after trying all the passphrases registered by the
.Fn archive_read_add_passphrase
function failed.
.El
.\" .Sh ERRORS
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_read_set_options 3
.Xr archive_read_set_options 3 ,
.Xr libarchive 3

View File

@ -28,7 +28,7 @@
.Dt ARCHIVE_READ_DATA 3
.Os
.Sh NAME
.Nm archive_read_data
.Nm archive_read_data ,
.Nm archive_read_data_block ,
.Nm archive_read_data_skip ,
.Nm archive_read_data_into_fd
@ -118,7 +118,6 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_read_extract 3 ,
.Xr archive_read_filter 3 ,
@ -127,4 +126,5 @@ functions.
.Xr archive_read_open 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr libarchive 3 ,
.Xr tar 5

View File

@ -99,9 +99,10 @@ following values:
.Bl -tag -compact -width "indent"
.It Cm ARCHIVE_READDISK_HONOR_NODUMP
Skip files and directories with the nodump file attribute (file flag) set.
By default, the nodump file atrribute is ignored.
By default, the nodump file attribute is ignored.
.It Cm ARCHIVE_READDISK_MAC_COPYFILE
Mac OS X specific. Read metadata (ACLs and extended attributes) with
Mac OS X specific.
Read metadata (ACLs and extended attributes) with
.Xr copyfile 3 .
By default, metadata is read using
.Xr copyfile 3 .
@ -120,7 +121,7 @@ or
for more information on file attributes.
.It Cm ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS
Do not traverse mount points.
By defaut, moint points are traversed.
By default, mount points are traversed.
.It Cm ARCHIVE_READDISK_NO_XATTR
Do not read extended file attributes (xattrs).
By default, extended file attributes are read from disk.
@ -216,7 +217,7 @@ of some other operation.
(For example, directory traversal libraries often provide this information.)
.Pp
Where necessary, user and group ids are converted to user and group names
using the currently registered lookup functions above.
using the currently-registered lookup functions above.
This affects the file ownership fields and ACL values in the
.Tn struct archive_entry
object.
@ -226,7 +227,7 @@ More information about the
object and the overall design of the library can be found in the
.Xr libarchive 3
overview.
.Sh EXAMPLE
.Sh EXAMPLES
The following illustrates basic usage of the library by
showing how to use it to copy an item on disk into an archive.
.Bd -literal -offset indent
@ -291,11 +292,11 @@ and
functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr archive_read 3 ,
.Xr archive_util 3 ,
.Xr archive_write 3 ,
.Xr archive_write_disk 3 ,
.Xr tar 1 ,
.Xr libarchive 3
.Sh HISTORY
The

View File

@ -126,7 +126,6 @@ and
functions.
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_filter 3 ,
@ -134,4 +133,5 @@ functions.
.Xr archive_read_open 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr libarchive 3 ,
.Xr tar 5

View File

@ -147,8 +147,8 @@ and
functions.
.\"
.Sh SEE ALSO
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_format 3 ,
.Xr archive_read_format 3
.Xr archive_read_format 3 ,
.Xr libarchive 3

View File

@ -102,7 +102,7 @@ For example,
.Fn archive_read_support_format_tar
enables support for a variety of standard tar formats, old-style tar,
ustar, pax interchange format, and many common variants.
.It Fn archive_read_support_format_all
.It Fn archive_read_support_format_all
Enables support for all available formats except the
.Dq raw
format (see below).
@ -125,7 +125,7 @@ it is not possible to accurately determine a format for
an empty file based purely on contents.
So empty files are treated by libarchive as a distinct
format.
.It Fn archive_read_support_format_raw
.It Fn archive_read_support_format_raw
The
.Dq raw
format handler allows libarchive to be used to read arbitrary data.
@ -153,11 +153,11 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_filter 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr libarchive 3 ,
.Xr tar 5
.Sh BUGS
Many traditional archiver programs treat

View File

@ -83,11 +83,11 @@ and
functions.
.\"
.Sh SEE ALSO
.Xr libarchive 3 ,
.Xr archive_read_new 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_filter 3 ,
.Xr archive_read_format 3 ,
.Xr archive_read_new 3 ,
.Xr archive_read_open 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3
.Xr archive_util 3 ,
.Xr libarchive 3

View File

@ -79,7 +79,6 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_extract 3 ,
@ -88,4 +87,5 @@ functions.
.Xr archive_read_open 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr libarchive 3 ,
.Xr tar 5

View File

@ -50,10 +50,10 @@ object can be found in the overview manual page for
.\" .Sh ERRORS
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_filter 3 ,
.Xr archive_read_format 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr libarchive 3 ,
.Xr tar 5

View File

@ -205,7 +205,7 @@ On failure, the callback should invoke
.Fn archive_set_error
to register an error code and message and
return
.Cm ARCHIVE_FATAL.
.Cm ARCHIVE_FATAL .
.\" .Sh EXAMPLE
.\"
.Sh RETURN VALUES
@ -223,11 +223,11 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_read_data 3 ,
.Xr archive_read_filter 3 ,
.Xr archive_read_format 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr libarchive 3 ,
.Xr tar 5

View File

@ -212,7 +212,8 @@ Use
to disable.
.It Cm read_concatenated_archives
Ignore zeroed blocks in the archive, which occurs when multiple tar archives
have been concatenated together. Without this option, only the contents of
have been concatenated together.
Without this option, only the contents of
the first concatenated archive would be read.
.El
.El
@ -226,6 +227,6 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_write_set_options 3 ,
.Xr archive_read 3
.Xr libarchive 3

View File

@ -131,12 +131,20 @@ archive_read_support_filter_gzip(struct archive *_a)
*/
static ssize_t
peek_at_header(struct archive_read_filter *filter, int *pbits,
struct private_data *state)
#ifdef HAVE_ZLIB_H
struct private_data *state
#else
void *state
#endif
)
{
const unsigned char *p;
ssize_t avail, len;
int bits = 0;
int header_flags;
#ifndef HAVE_ZLIB_H
(void)state; /* UNUSED */
#endif
/* Start by looking at the first ten bytes of the header, which
* is all fixed layout. */
@ -153,8 +161,10 @@ peek_at_header(struct archive_read_filter *filter, int *pbits,
bits += 3;
header_flags = p[3];
/* Bytes 4-7 are mod time in little endian. */
#ifdef HAVE_ZLIB_H
if (state)
state->mtime = archive_le32dec(p + 4);
#endif
/* Byte 8 is deflate flags. */
/* XXXX TODO: return deflate flags back to consume_header for use
in initializing the decompressor. */
@ -171,7 +181,9 @@ peek_at_header(struct archive_read_filter *filter, int *pbits,
/* Null-terminated optional filename. */
if (header_flags & 8) {
#ifdef HAVE_ZLIB_H
ssize_t file_start = len;
#endif
do {
++len;
if (avail < len)
@ -181,11 +193,13 @@ peek_at_header(struct archive_read_filter *filter, int *pbits,
return (0);
} while (p[len - 1] != 0);
#ifdef HAVE_ZLIB_H
if (state) {
/* Reset the name in case of repeat header reads. */
free(state->name);
state->name = strdup((const char *)&p[file_start]);
}
#endif
}
/* Null-terminated optional comment. */
@ -236,24 +250,6 @@ gzip_bidder_bid(struct archive_read_filter_bidder *self,
return (0);
}
static int
gzip_read_header(struct archive_read_filter *self, struct archive_entry *entry)
{
struct private_data *state;
state = (struct private_data *)self->data;
/* A mtime of 0 is considered invalid/missing. */
if (state->mtime != 0)
archive_entry_set_mtime(entry, state->mtime, 0);
/* If the name is available, extract it. */
if (state->name)
archive_entry_set_pathname(entry, state->name);
return (ARCHIVE_OK);
}
#ifndef HAVE_ZLIB_H
/*
@ -277,6 +273,24 @@ gzip_bidder_init(struct archive_read_filter *self)
#else
static int
gzip_read_header(struct archive_read_filter *self, struct archive_entry *entry)
{
struct private_data *state;
state = (struct private_data *)self->data;
/* A mtime of 0 is considered invalid/missing. */
if (state->mtime != 0)
archive_entry_set_mtime(entry, state->mtime, 0);
/* If the name is available, extract it. */
if (state->name)
archive_entry_set_pathname(entry, state->name);
return (ARCHIVE_OK);
}
/*
* Initialize the filter object.
*/
@ -306,7 +320,9 @@ gzip_bidder_init(struct archive_read_filter *self)
self->read = gzip_filter_read;
self->skip = NULL; /* not supported */
self->close = gzip_filter_close;
#ifdef HAVE_ZLIB_H
self->read_header = gzip_read_header;
#endif
state->in_stream = 0; /* We're not actually within a stream yet. */

View File

@ -460,7 +460,7 @@ lz4_filter_read_descriptor(struct archive_read_filter *self)
__archive_read_filter_consume(self->upstream, descriptor_bytes);
/* Make sure we have an enough buffer for uncompressed data. */
/* Make sure we have a large enough buffer for uncompressed data. */
if (lz4_allocate_out_block(self) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
if (state->flags.stream_checksum)
@ -520,7 +520,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
if (read_buf == NULL)
goto truncated_error;
/* Optional process, checking a block sum. */
/* Optional processing, checking a block sum. */
if (checksum_size) {
unsigned int chsum = __archive_xxhash.XXH32(
read_buf + 4, (int)compressed_size, 0);
@ -640,7 +640,7 @@ lz4_filter_read_default_stream(struct archive_read_filter *self, const void **p)
if (ret == 0 && *p == NULL)
state->stage = SELECT_STREAM;
/* Optional process, checking a stream sum. */
/* Optional processing, checking a stream sum. */
if (state->flags.stream_checksum) {
if (state->stage == SELECT_STREAM) {
unsigned int checksum;
@ -660,7 +660,7 @@ lz4_filter_read_default_stream(struct archive_read_filter *self, const void **p)
if (checksum != checksum_stream) {
archive_set_error(&self->archive->archive,
ARCHIVE_ERRNO_MISC,
"lz4 stream cheksum error");
"lz4 stream checksum error");
return (ARCHIVE_FATAL);
}
} else if (ret > 0)
@ -674,7 +674,7 @@ static ssize_t
lz4_filter_read_legacy_stream(struct archive_read_filter *self, const void **p)
{
struct private_data *state = (struct private_data *)self->data;
int compressed;
uint32_t compressed;
const char *read_buf;
ssize_t ret;

View File

@ -487,7 +487,7 @@ process_extra(struct archive_read *a, struct archive_entry *entry,
/* Some ZIP files may have trailing 0 bytes. Let's check they
* are all 0 and ignore them instead of returning an error.
*
* This is not techincally correct, but some ZIP files look
* This is not technically correct, but some ZIP files look
* like this and other tools support those files - so let's
* also support them.
*/
@ -1053,7 +1053,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
/* Make sure that entries with a trailing '/' are marked as directories
* even if the External File Attributes contains bogus values. If this
* is not a directory and there is no type, assume regularfile. */
* is not a directory and there is no type, assume a regular file. */
if ((zip_entry->mode & AE_IFMT) != AE_IFDIR) {
int has_slash;
@ -1104,7 +1104,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
}
if (zip_entry->flags & LA_FROM_CENTRAL_DIRECTORY) {
/* If this came from the central dir, it's size info
/* If this came from the central dir, its size info
* is definitive, so ignore the length-at-end flag. */
zip_entry->zip_flags &= ~ZIP_LENGTH_AT_END;
/* If local header is missing a value, use the one from

View File

@ -458,7 +458,7 @@ archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest,
if (from_cp == CP_C_LOCALE) {
/*
* "C" locale special process.
* "C" locale special processing.
*/
wchar_t *ws;
const unsigned char *mp;
@ -680,7 +680,7 @@ archive_string_append_from_wcs_in_codepage(struct archive_string *as,
if (to_cp == CP_C_LOCALE) {
/*
* "C" locale special process.
* "C" locale special processing.
*/
const wchar_t *wp = ws;
char *p;
@ -889,7 +889,7 @@ add_converter(struct archive_string_conv *sc, int (*converter)
struct archive_string_conv *))
{
if (sc == NULL || sc->nconverter >= 2)
__archive_errx(1, "Programing error");
__archive_errx(1, "Programming error");
sc->converter[sc->nconverter++] = converter;
}

View File

@ -92,10 +92,10 @@ Clears any error information left over from a previous call.
Not generally used in client code.
.It Fn archive_compression
Synonym for
.Fn archive_filter_code(a, 0) .
.Fn archive_filter_code a 0 .
.It Fn archive_compression_name
Synonym for
.Fn archive_filter_name(a, 0) .
.Fn archive_filter_name a 0 .
.It Fn archive_copy_error
Copies error information from one archive to another.
.It Fn archive_errno
@ -142,13 +142,13 @@ filter 0 is the gunzip filter,
filter 1 is the uudecode filter,
and filter 2 is the pseudo-filter that wraps the archive read functions.
In this case, requesting
.Fn archive_position(a, -1)
.Fn archive_position a -1
would be a synonym for
.Fn archive_position(a, 2)
.Fn archive_position a 2
which would return the number of bytes currently read from the archive, while
.Fn archive_position(a, 1)
.Fn archive_position a 1
would return the number of bytes after uudecoding, and
.Fn archive_position(a, 0)
.Fn archive_position a 0
would return the number of bytes after decompression.
.It Fn archive_filter_name
Returns a textual name identifying the indicated filter.
@ -170,9 +170,9 @@ A textual description of the format of the current entry.
.It Fn archive_position
Returns the number of bytes read from or written to the indicated filter.
In particular,
.Fn archive_position(a, 0)
.Fn archive_position a 0
returns the number of bytes read or written by the format handler, while
.Fn archive_position(a, -1)
.Fn archive_position a -1
returns the number of bytes read or written to the archive.
See
.Fn archive_filter_count

View File

@ -118,7 +118,7 @@ After all entries have been written, use the
.Fn archive_write_free
function to release all resources.
.\"
.Sh EXAMPLE
.Sh EXAMPLES
The following sketch illustrates basic usage of the library.
In this example,
the callback functions are simply wrappers around the standard
@ -192,7 +192,7 @@ write_archive(const char *outname, const char **filename)
if (archive_write_set_format_filter_by_ext(a, outname) != ARCHIVE_OK) {
archive_write_add_filter_gzip(a);
archive_write_set_format_ustar(a);
}
}
archive_write_open(a, mydata, myopen, mywrite, myclose);
while (*filename) {
stat(*filename, &st);
@ -225,8 +225,8 @@ int main(int argc, const char **argv)
.Ed
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -107,8 +107,8 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -82,9 +82,9 @@ and consider any non-negative value as success.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write_finish_entry 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -113,7 +113,8 @@ or
.Pq FreeBSD, Mac OS X
for more information on file attributes.
.It Cm ARCHIVE_EXTRACT_MAC_METADATA
Mac OS X specific. Restore metadata using
Mac OS X specific.
Restore metadata using
.Xr copyfile 3 .
By default,
.Xr copyfile 3
@ -264,9 +265,9 @@ and
functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr archive_read 3 ,
.Xr archive_write 3 ,
.Xr tar 1 ,
.Xr libarchive 3
.Sh HISTORY
The

View File

@ -431,7 +431,7 @@ la_opendirat(int fd, const char *path) {
errno = ENOTSUP;
return (-1);
} else
return (open(fd, path, flags));
return (open(path, flags));
#else
return (openat(fd, path, flags));
#endif

View File

@ -43,7 +43,7 @@
.Nm archive_write_add_filter_program ,
.Nm archive_write_add_filter_uuencode ,
.Nm archive_write_add_filter_xz ,
.Nm archive_write_add_filter_zstd ,
.Nm archive_write_add_filter_zstd
.Nd functions enabling output filters
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@ -125,10 +125,10 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write 3 ,
.Xr archive_write_format 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -71,9 +71,9 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write_data 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -52,7 +52,7 @@
.Nm archive_write_set_format_v7tar ,
.Nm archive_write_set_format_warc ,
.Nm archive_write_set_format_xar ,
.Nm archive_write_set_format_zip ,
.Nm archive_write_set_format_zip
.Nd functions for creating archives
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@ -166,9 +166,9 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr libarchive-formats 5 ,
.Xr mtree 5 ,

View File

@ -56,7 +56,7 @@ after calling this function, the only call that can succeed is
to release the resources.
This can be used to speed recovery when the archive creation
must be aborted.
Note that the created archive is likely to be malformed in this case;
Note that the created archive is likely to be malformed in this case;
.It Fn archive_write_close
Complete the archive and invoke the close callback.
.It Fn archive_write_finish
@ -89,8 +89,8 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -66,8 +66,8 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -50,9 +50,9 @@ object can be found in the overview manual page for
.\" .Sh ERRORS
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -200,7 +200,7 @@ On failure, the callback should invoke
.Fn archive_set_error
to register an error code and message and
return
.Cm ARCHIVE_FATAL.
.Cm ARCHIVE_FATAL .
.Pp
Note that if the client-provided write callback function
returns a non-zero value, that error will be propagated back to the caller
@ -234,13 +234,13 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write 3 ,
.Xr archive_write_blocksize 3 ,
.Xr archive_write_filter 3 ,
.Xr archive_write_format 3 ,
.Xr archive_write_new 3 ,
.Xr archive_write_set_options 3 ,
.Xr libarchive 3 ,
.Xr cpio 5 ,
.Xr mtree 5 ,
.Xr tar 5

View File

@ -3650,7 +3650,7 @@ wb_consume(struct archive_write *a, size_t size)
if (size > iso9660->wbuff_remaining ||
iso9660->wbuff_remaining == 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Internal Programing error: iso9660:wb_consume()"
"Internal Programming error: iso9660:wb_consume()"
" size=%jd, wbuff_remaining=%jd",
(intmax_t)size, (intmax_t)iso9660->wbuff_remaining);
return (ARCHIVE_FATAL);
@ -3671,7 +3671,7 @@ wb_set_offset(struct archive_write *a, int64_t off)
if (iso9660->wbuff_type != WB_TO_TEMP) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Internal Programing error: iso9660:wb_set_offset()");
"Internal Programming error: iso9660:wb_set_offset()");
return (ARCHIVE_FATAL);
}
@ -8128,7 +8128,7 @@ zisofs_write_to_temp(struct archive_write *a, const void *buff, size_t s)
{
(void)buff; /* UNUSED */
(void)s; /* UNUSED */
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Programing error");
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Programming error");
return (ARCHIVE_FATAL);
}

View File

@ -186,7 +186,7 @@ struct mtree_writer {
#endif
/* Keyword options */
int keys;
#define F_CKSUM 0x00000001 /* check sum */
#define F_CKSUM 0x00000001 /* checksum */
#define F_DEV 0x00000002 /* device type */
#define F_DONE 0x00000004 /* directory done */
#define F_FLAGS 0x00000008 /* file flags */
@ -371,7 +371,7 @@ mtree_quote(struct archive_string *s, const char *str)
}
/*
* Indent a line as mtree utility to be readable for people.
* Indent a line as the mtree utility does so it is readable for people.
*/
static void
mtree_indent(struct mtree_writer *mtree)
@ -446,8 +446,8 @@ mtree_indent(struct mtree_writer *mtree)
/*
* Write /set keyword.
* Set most used value of uid,gid,mode and fflags, which are
* collected by attr_counter_set_collect() function.
* Set the most used value of uid, gid, mode and fflags, which are
* collected by the attr_counter_set_collect() function.
*/
static void
write_global(struct mtree_writer *mtree)
@ -649,7 +649,7 @@ attr_counter_inc(struct attr_counter **top, struct attr_counter *ac,
}
/*
* Tabulate uid,gid,mode and fflags of a entry in order to be used for /set.
* Tabulate uid, gid, mode and fflags of a entry in order to be used for /set.
*/
static int
attr_counter_set_collect(struct mtree_writer *mtree, struct mtree_entry *me)
@ -912,7 +912,7 @@ archive_write_mtree_header(struct archive_write *a,
/* If the current file is a regular file, we have to
* compute the sum of its content.
* Initialize a bunch of sum check context. */
* Initialize a bunch of checksum context. */
if (mtree_entry->reg_info)
sum_init(mtree);
@ -1265,7 +1265,7 @@ archive_write_mtree_free(struct archive_write *a)
if (mtree == NULL)
return (ARCHIVE_OK);
/* Make sure we dot not leave any entries. */
/* Make sure we do not leave any entries. */
mtree_entry_register_free(mtree);
archive_string_free(&mtree->cur_dirstr);
archive_string_free(&mtree->ebuf);
@ -2024,7 +2024,7 @@ mtree_entry_tree_add(struct archive_write *a, struct mtree_entry **filep)
if (file->parentdir.length == 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Internal programing error "
"Internal programming error "
"in generating canonical name for %s",
file->pathname.s);
return (ARCHIVE_FAILED);

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 2, 2012
.Dd July 27, 2019
.Dt ARCHIVE_WRITE_OPTIONS 3
.Os
.Sh NAME
@ -70,7 +70,7 @@ specific write modules.
.Fn archive_write_set_filter_option ,
.Fn archive_write_set_format_option
.Xc
Specifies an option that will be passed to currently-registered
Specifies an option that will be passed to the currently-registered
filters (including decompression filters) or format readers.
.Pp
If
@ -138,7 +138,7 @@ If either function returns
.Cm ARCHIVE_FATAL
will be returned
immediately.
Otherwise, greater of the two values will be returned.
Otherwise, the greater of the two values will be returned.
.\"
.It Fn archive_write_set_options
.Ar options
@ -203,22 +203,28 @@ These options are used to set standard ISO9660 metadata.
.Bl -tag -compact -width indent
.It Cm abstract-file Ns = Ns Ar filename
The file with the specified name will be identified in the ISO9660 metadata
as holding the abstract for this volume. Default: none.
as holding the abstract for this volume.
Default: none.
.It Cm application-id Ns = Ns Ar filename
The file with the specified name will be identified in the ISO9660 metadata
as holding the application identifier for this volume. Default: none.
as holding the application identifier for this volume.
Default: none.
.It Cm biblio-file Ns = Ns Ar filename
The file with the specified name will be identified in the ISO9660 metadata
as holding the bibliography for this volume. Default: none.
as holding the bibliography for this volume.
Default: none.
.It Cm copyright-file Ns = Ns Ar filename
The file with the specified name will be identified in the ISO9660 metadata
as holding the copyright for this volume. Default: none.
as holding the copyright for this volume.
Default: none.
.It Cm publisher Ns = Ns Ar filename
The file with the specified name will be identified in the ISO9660 metadata
as holding the publisher information for this volume. Default: none.
as holding the publisher information for this volume.
Default: none.
.It Cm volume-id Ns = Ns Ar string
The specified string will be used as the Volume Identifier in the ISO9660 metadata.
It is limited to 32 bytes. Default: none.
It is limited to 32 bytes.
Default: none.
.El
.It Format iso9660 - boot support
These options are used to make an ISO9660 image that can be directly
@ -266,7 +272,7 @@ If the boot image is exactly 1.2MB, 1.44MB, or 2.88MB, then
the default is
.Cm fd ,
otherwise the default is
.Cm no-emulation.
.Cm no-emulation .
.El
.It Format iso9660 - filename and size extensions
Various extensions to the base ISO9660 format.
@ -290,7 +296,7 @@ This does not impact names stored in the Rockridge or Joliet extension area.
Default: disabled.
.It Cm allow-period
If enabled, allows filenames to contain trailing period characters, in violation of the ISO9660 specification.
If disabled,trailing periods will be converted to underscore characters.
If disabled, trailing periods will be converted to underscore characters.
This does not impact names stored in the Rockridge or Joliet extension area.
Default: disabled.
.It Cm allow-pvd-lowercase
@ -398,6 +404,27 @@ Specifies a filename that should not be compressed when using
This option can be provided multiple times to suppress compression
on many files.
.El
.It Format 7zip
.Bl -tag -compact -width indent
.It Cm compression
The value is one of
.Dq store ,
.Dq deflate ,
.Dq bzip2 ,
.Dq lzma1 ,
.Dq lzma2
or
.Dq ppmd
to indicate how the following entries should be compressed.
Note that this setting is ignored for directories, symbolic links,
and other special entries.
.It Cm compression-level
The value is interpreted as a decimal integer specifying the
compression level.
Values between 0 and 9 are supported.
The interpretation of the compression level depends on the chosen
compression method.
.El
.It Format zip
.Bl -tag -compact -width indent
.It Cm compression
@ -408,6 +435,15 @@ or
to indicate how the following entries should be compressed.
Note that this setting is ignored for directories, symbolic links,
and other special entries.
.It Cm compression-level
The value is interpreted as a decimal integer specifying the
compression level.
Values between 0 and 9 are supported.
A compression level of 0 switches the compression method to
.Dq store ,
other values will enable
.Dq deflate
compression with the given level.
.It Cm experimental
This boolean option enables or disables experimental Zip features
that may not be compatible with other Zip implementations.
@ -465,9 +501,9 @@ functions.
.\"
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_write 3
.Xr archive_write 3 ,
.Xr libarchive 3
.Sh HISTORY
The
.Nm libarchive

View File

@ -49,7 +49,7 @@ Streaming Archive Library (libarchive, -larchive)
.Sh DESCRIPTION
.Bl -tag -width indent
.It Fn archive_write_set_passphrase
Set a passphrase for writing an encryption archive.
Set a passphrase for writing an encrypted archive.
If
.Ar passphrase
is
@ -59,16 +59,16 @@ or empty, this function will do nothing and
will be returned.
Otherwise,
.Cm ARCHIVE_OK
will be returned.
will be returned.
.It Fn archive_write_set_passphrase_callback
Register callback function that will be invoked to get a passphrase
for encrption if the passphrase was not set by the
Register a callback function that will be invoked to get a passphrase
for encryption if the passphrase was not set by the
.Fn archive_write_set_passphrase
function.
.El
.\" .Sh ERRORS
.Sh SEE ALSO
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write 3 ,
.Xr archive_write_set_options 3
.Xr archive_write_set_options 3 ,
.Xr libarchive 3

View File

@ -35,7 +35,6 @@
This page describes user-visible changes in libarchive3, and lists
public functions and other symbols changed, deprecated or removed
in libarchive3, along with their replacements if any.
.Pp
.\"
.Ss Multiple Filters
.\"
@ -330,13 +329,13 @@ or
.Li 10240
.El
.Sh SEE ALSO
.Xr libarchive 3 ,
.Xr archive_read 3 ,
.Xr archive_read_filter 3 ,
.Xr archive_read_format 3 ,
.Xr archive_read_set_options 3 ,
.Xr archive_util 3 ,
.Xr archive_write 3 ,
.Xr archive_write_filter 3 ,
.Xr archive_write_format 3 ,
.Xr archive_write_set_options 3 ,
.Xr archive_util 3
.Xr libarchive 3

View File

@ -350,8 +350,8 @@ as a dedicated ZIP program.
.Xr archive_entry 3 ,
.Xr archive_read 3 ,
.Xr archive_write 3 ,
.Xr archive_write_disk 3
.Xr libarchive 3 ,
.Xr archive_write_disk 3 ,
.Xr libarchive 3
.Sh HISTORY
The
.Nm libarchive

View File

@ -441,7 +441,7 @@ archives to store files much larger than the historic 8GB limit.
Vendor-specific attributes used by Joerg Schilling's
.Nm star
implementation.
.It Cm SCHILY.acl.access , Cm SCHILY.acl.default, Cm SCHILY.acl.ace
.It Cm SCHILY.acl.access , Cm SCHILY.acl.default , Cm SCHILY.acl.ace
Stores the access, default and NFSv4 ACLs as textual strings in a format
that is an extension of the format specified by POSIX.1e draft 17.
In particular, each user or group access specification can include
@ -456,7 +456,7 @@ The file flags.
.It Cm SCHILY.realsize
The full size of the file on disk.
XXX explain? XXX
.It Cm SCHILY.dev, Cm SCHILY.ino , Cm SCHILY.nlinks
.It Cm SCHILY.dev , Cm SCHILY.ino , Cm SCHILY.nlinks
The device number, inode number, and link count for the entry.
In particular, note that a pax interchange format archive using Joerg
Schilling's
@ -473,7 +473,7 @@ The time when the file was created.
.Dq ctime
attribute, which refers to the time when the file
metadata was last changed.)
.It Cm LIBARCHIVE.xattr. Ns Ar namespace Ns . Ns Ar key
.It Cm LIBARCHIVE.xattr . Ns Ar namespace . Ns Ar key
Libarchive stores POSIX.1e-style extended attributes using
keys of this form.
The
@ -890,7 +890,8 @@ GNU tar long pathname for the following header.
.It Cm M
GNU tar multivolume marker, indicating the file is a continuation of a file from the previous volume.
.It Cm N
GNU tar long filename support. Deprecated.
GNU tar long filename support.
Deprecated.
.It Cm S
GNU tar sparse regular file.
.It Cm V

View File

@ -48,7 +48,7 @@ test_filter_by_name(const char *filter_name, int filter_code,
r = archive_write_add_filter_by_name(a, filter_name);
if (r == ARCHIVE_WARN) {
if (!can_filter_prog()) {
skipping("%s filter not suported on this platform",
skipping("%s filter not supported on this platform",
filter_name);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
free(buff);
@ -59,7 +59,7 @@ test_filter_by_name(const char *filter_name, int filter_code,
"lzma compression not supported on this platform") == 0 ||
strcmp(archive_error_string(a),
"xz compression not supported on this platform") == 0)) {
skipping("%s filter not suported on this platform", filter_name);
skipping("%s filter not supported on this platform", filter_name);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
free(buff);
return;

View File

@ -61,7 +61,7 @@ test_format_filter_by_ext(const char *output_file,
strcmp(archive_error_string(a),
"xz compression not supported on this platform") == 0)) {
const char *filter_name = archive_filter_name(a, 0);
skipping("%s filter not suported on this platform", filter_name);
skipping("%s filter not supported on this platform", filter_name);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
free(buff);
return;

View File

@ -36,7 +36,9 @@ DEFINE_TEST(test_read_format_raw)
const char *reffile1 = "test_read_format_raw.data";
const char *reffile2 = "test_read_format_raw.data.Z";
const char *reffile3 = "test_read_format_raw.bufr";
#ifdef HAVE_ZLIB_H
const char *reffile4 = "test_read_format_raw.data.gz";
#endif
/* First, try pulling data out of an uninterpretable file. */
extract_reference_file(reffile1);
@ -119,6 +121,7 @@ DEFINE_TEST(test_read_format_raw)
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
#ifdef HAVE_ZLIB_H
/* Fourth, try with gzip which has metadata. */
extract_reference_file(reffile4);
assert((a = archive_read_new()) != NULL);
@ -144,4 +147,5 @@ DEFINE_TEST(test_read_format_raw)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
#endif
}

View File

@ -139,7 +139,7 @@ verify_basic(struct archive *a, int seek_checks)
} else {
assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
assertEqualString(archive_error_string(a),
"Unsupported ZIP compression method (deflation)");
"Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
@ -162,7 +162,7 @@ verify_basic(struct archive *a, int seek_checks)
} else {
assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
assertEqualString(archive_error_string(a),
"Unsupported ZIP compression method (deflation)");
"Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
@ -231,7 +231,7 @@ verify_info_zip_ux(struct archive *a, int seek_checks)
} else {
assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
assertEqualString(archive_error_string(a),
"Unsupported ZIP compression method (deflation)");
"Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@ -302,7 +302,7 @@ verify_extract_length_at_end(struct archive *a, int seek_checks)
} else {
assertEqualIntA(a, ARCHIVE_FAILED, archive_read_extract(a, ae, 0));
assertEqualString(archive_error_string(a),
"Unsupported ZIP compression method (deflation)");
"Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}

View File

@ -130,7 +130,7 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
assertEqualInt(ARCHIVE_FAILED,
archive_read_data(a, buff, sizeof(buff)));
assertEqualString(archive_error_string(a),
"Unsupported ZIP compression method (deflation)");
"Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
@ -148,7 +148,7 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
assertEqualInt(ARCHIVE_FAILED,
archive_read_data(a, buff, sizeof(buff)));
assertEqualString(archive_error_string(a),
"Unsupported ZIP compression method (deflation)");
"Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}

View File

@ -34,7 +34,7 @@ DEFINE_TEST(test_write_filter_zstd)
char *buff, *data;
size_t buffsize, datasize;
char path[16];
size_t used1, used2;
size_t used1, used2, used3;
int i, r;
buffsize = 2000000;
@ -125,7 +125,7 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_set_filter_option(a, NULL, "compression-level", "9"));
assertEqualIntA(a, ARCHIVE_OK,
archive_write_set_filter_option(a, NULL, "compression-level", "6"));
archive_write_set_filter_option(a, NULL, "compression-level", "7"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
sprintf(path, "file%03d", i);
@ -140,10 +140,6 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
failure("compression-level=6 wrote %d bytes, default wrote %d bytes",
(int)used2, (int)used1);
assert(used2 < used1);
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
r = archive_read_support_filter_zstd(a);
@ -167,6 +163,64 @@ DEFINE_TEST(test_write_filter_zstd)
}
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
/*
* One more time at level 1
*/
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_write_set_bytes_per_block(a, 10));
assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_zstd(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_write_set_filter_option(a, NULL, "compression-level", "1"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used3));
assert((ae = archive_entry_new()) != NULL);
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize == (size_t)archive_write_data(a, data, datasize));
}
archive_entry_free(ae);
assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
r = archive_read_support_filter_zstd(a);
if (r == ARCHIVE_WARN) {
skipping("zstd reading not fully supported on this platform");
} else {
assertEqualIntA(a, ARCHIVE_OK,
archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used3));
for (i = 0; i < 100; i++) {
sprintf(path, "file%03d", i);
failure("Trying to read %s", path);
if (!assertEqualIntA(a, ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
assertEqualInt((int)datasize, archive_entry_size(ae));
}
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
}
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
/*
* Check output sizes for various compression levels, expectation
* is that archive size for level=7 < default < level=1
*/
failure("compression-level=7 wrote %d bytes, default wrote %d bytes",
(int)used2, (int)used1);
assert(used2 < used1);
failure("compression-level=1 wrote %d bytes, default wrote %d bytes",
(int)used3, (int)used1);
assert(used1 < used3);
/*
* Test various premature shutdown scenarios to make sure we
* don't crash or leak memory.

View File

@ -167,12 +167,14 @@ if it is unknown suffix or no suffix, creates a new archive with
restricted pax format and bzip2 compression.
.It Fl Fl acls
(c, r, u, x modes only)
Archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of
Archive or extract POSIX.1e or NFSv4 ACLs.
This is the reverse of
.Fl Fl no-acls
and the default behavior in c, r, and u modes (except on Mac OS X) or if
.Nm
is run in x mode as root. On Mac OS X this option translates extended ACLs
to NFSv4 ACLs. To store extended ACLs the
is run in x mode as root.
On Mac OS X this option translates extended ACLs to NFSv4 ACLs.
To store extended ACLs the
.Fl Fl mac-metadata
option is preferred.
.It Fl B , Fl Fl read-full-blocks
@ -390,10 +392,12 @@ Do not extract modification time.
By default, the modification time is set to the time stored in the archive.
.It Fl Fl mac-metadata
(c, r, u and x mode only)
Mac OS X specific. Archive or extract extended ACLs and extended file
Mac OS X specific.
Archive or extract extended ACLs and extended file
attributes using
.Xr copyfile 3
in AppleDouble format. This is the reverse of
in AppleDouble format.
This is the reverse of
.Fl Fl no-mac-metadata .
and the default behavior in c, r, and u modes or if
.Nm
@ -439,24 +443,28 @@ option to
.Xr find 1 .
.It Fl Fl no-acls
(c, r, u, x modes only)
Do not archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of
Do not archive or extract POSIX.1e or NFSv4 ACLs.
This is the reverse of
.Fl Fl acls
and the default behavior if
.Nm
is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
.It Fl Fl no-fflags
(c, r, u, x modes only)
Do not archive or extract file attributes or file flags. This is the reverse of
Do not archive or extract file attributes or file flags.
This is the reverse of
.Fl Fl fflags
and the default behavior if
.Nm
is run as non-root in x mode.
.It Fl Fl no-mac-metadata
(x mode only)
Mac OS X specific. Do not archive or extract ACLs and extended file attributes
Mac OS X specific.
Do not archive or extract ACLs and extended file attributes
using
.Xr copyfile 3
in AppleDouble format. This is the reverse of
in AppleDouble format.
This is the reverse of
.Fl Fl mac-metadata .
and the default behavior if
.Nm
@ -480,7 +488,8 @@ and the default behavior if
is run as non-root.
.It Fl Fl no-xattrs
(c, r, u, x modes only)
Do not archive or extract extended file attributes. This is the reverse of
Do not archive or extract extended file attributes.
This is the reverse of
.Fl Fl xattrs
and the default behavior if
.Nm
@ -577,7 +586,8 @@ to disable.
.It Cm gzip:compression-level
A decimal integer from 1 to 9 specifying the gzip compression level.
.It Cm gzip:timestamp
Store timestamp. This is enabled by default, use
Store timestamp.
This is enabled by default, use
.Cm !timestamp
or
.Cm gzip:!timestamp
@ -593,7 +603,8 @@ A decimal integer from 1 to 9 specifying the lrzip compression level.
.It Cm lz4:compression-level
A decimal integer from 1 to 9 specifying the lzop compression level.
.It Cm lz4:stream-checksum
Enable stream checksum. This is by default, use
Enable stream checksum.
This is by default, use
.Cm lz4:!stream-checksum
to disable.
.It Cm lz4:block-checksum
@ -646,9 +657,10 @@ Supported values are zipcrypt (traditional zip encryption),
aes128 (WinZip AES-128 encryption) and aes256 (WinZip AES-256 encryption).
.It Cm read_concatenated_archives
Ignore zeroed blocks in the archive, which occurs when multiple tar archives
have been concatenated together. Without this option, only the contents of
the first concatenated archive would be read. This option is comparable to
the
have been concatenated together.
Without this option, only the contents of
the first concatenated archive would be read.
This option is comparable to the
.Fl i , Fl Fl ignore-zeros
option of GNU tar.
.El
@ -670,11 +682,13 @@ This option suppresses these behaviors.
Preserve file permissions.
Attempt to restore the full permissions, including file modes, file attributes
or file flags, extended file attributes and ACLs, if available, for each item
extracted from the archive. This is the reverse of
extracted from the archive.
This is the reverse of
.Fl Fl no-same-permissions
and the default if
.Nm
is being run as root. It can be partially overridden by also specifying
is being run as root.
It can be partially overridden by also specifying
.Fl Fl no-acls ,
.Fl Fl no-fflags ,
.Fl Fl no-mac-metadata
@ -845,7 +859,8 @@ See
for more information about the handling of exclusions.
.It Fl Fl xattrs
(c, r, u, x modes only)
Archive or extract extended file attributes. This is the reverse of
Archive or extract extended file attributes.
This is the reverse of
.Fl Fl no-xattrs
and the default behavior in c, r, and u modes or if
.Nm
@ -937,9 +952,9 @@ To examine the contents of an ISO 9660 cdrom image:
To move file hierarchies, invoke
.Nm
as
.Dl Nm Fl cf Pa - Fl C Pa srcdir\ . | Nm Fl xpf Pa - Fl C Pa destdir
.Dl Nm Fl cf Pa - Fl C Pa srcdir \&. | Nm Fl xpf Pa - Fl C Pa destdir
or more traditionally
.Dl cd srcdir \&; Nm Fl cf Pa -\ . | ( cd destdir \&; Nm Fl xpf Pa - )
.Dl cd srcdir \&; Nm Fl cf Pa - \&. | ( cd destdir \&; Nm Fl xpf Pa - )
.Pp
In create mode, the list of files and directories to be archived
can also include directory change instructions of the form
@ -967,7 +982,6 @@ An input file in
.Xr mtree 5
format can be used to create an output archive with arbitrary ownership,
permissions, or names that differ from existing data on disk:
.Pp
.Bd -literal -offset indent
$ cat input.mtree
#mtree

View File

@ -120,7 +120,7 @@ DEFINE_TEST(test_option_n)
"d2/file4\n",
"test5.out");
/* Test 6: -t without -n and non-existant directory selected */
/* Test 6: -t without -n and non-existent directory selected */
assertEqualInt(0,
systemf("%s -tf partial-archive.tar d2 >test6.out 2>test6.err",
testprog));
@ -128,7 +128,7 @@ DEFINE_TEST(test_option_n)
assertTextFileContents("d2/file4\n",
"test6.out");
/* Test 7: -t with -n and non-existant directory selected */
/* Test 7: -t with -n and non-existent directory selected */
status = systemf("%s -tnf partial-archive.tar d2 "
">test7.out 2>test7.err", testprog);
assert(status);

View File

@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_option_xattrs)
{
#if !ARCHIVE_XATTR_SUPPORT
skipping("Extended atributes are not supported on this platform");
skipping("Extended attributes are not supported on this platform");
#else /* ARCHIVE_XATTR_SUPPORT */
const char *testattr = "user.libarchive.test";

View File

@ -298,7 +298,7 @@ my_CreateSymbolicLinkA(const char *linkname, const char *target,
ret = (*f)(src, tgt, tmpflags);
/*
* Prior to Windows 10 the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
* is not undestood
* is not understood
*/
if (!ret)
ret = (*f)(src, tgt, flags);

View File

@ -413,6 +413,60 @@ wflag_emptypat_body()
atf_check -o file:test4 grep -w -e "" test4
}
atf_test_case xflag_emptypat
xflag_emptypat_body()
{
printf "" > test1
printf "\n" > test2
printf "qaz" > test3
printf " qaz\n" > test4
# -x is whole-line, more strict than -w.
atf_check -s exit:1 -o empty grep -x -e "" test1
atf_check -o file:test2 grep -x -e "" test2
atf_check -s exit:1 -o empty grep -x -e "" test3
atf_check -s exit:1 -o empty grep -x -e "" test4
total=$(wc -l /COPYRIGHT | sed 's/[^0-9]//g')
# Simple checks that grep -x with an empty pattern isn't matching every
# line. The exact counts aren't important, as long as they don't
# match the total line count and as long as they don't match each other.
atf_check -o save:xpositive.count grep -Fxc '' /COPYRIGHT
atf_check -o save:xnegative.count grep -Fvxc '' /COPYRIGHT
atf_check -o not-inline:"${total}" cat xpositive.count
atf_check -o not-inline:"${total}" cat xnegative.count
atf_check -o not-file:xnegative.count cat xpositive.count
}
atf_test_case xflag_emptypat_plus
xflag_emptypat_plus_body()
{
printf "foo\n\nbar\n\nbaz\n" > target
printf "foo\n \nbar\n \nbaz\n" > target_spacelines
printf "foo\nbar\nbaz\n" > matches
printf " \n \n" > spacelines
printf "foo\n\nbar\n\nbaz\n" > patlist1
printf "foo\n\nba\n\nbaz\n" > patlist2
sed -e '/bar/d' target > matches_not2
# Normal handling first
atf_check -o file:target grep -Fxf patlist1 target
atf_check -o file:matches grep -Fxf patlist1 target_spacelines
atf_check -o file:matches_not2 grep -Fxf patlist2 target
# -v handling
atf_check -s exit:1 -o empty grep -Fvxf patlist1 target
atf_check -o file:spacelines grep -Fxvf patlist1 target_spacelines
}
atf_test_case excessive_matches
excessive_matches_head()
{
@ -551,6 +605,12 @@ grep_nomatch_flags_head()
grep_nomatch_flags_body()
{
grep_type
if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then
atf_expect_fail "this test does not pass with GNU grep in base"
fi
printf "A\nB\nC\n" > test1
atf_check -o inline:"1\n" grep -c -C 1 -e "B" test1
@ -563,7 +623,7 @@ grep_nomatch_flags_body()
atf_check -o inline:"test1\n" grep -l -A 1 -e "B" test1
atf_check -o inline:"test1\n" grep -l -C 1 -e "B" test1
atf_check -s exit:1 -o inline:"test1\n" grep -L -e "D" test1
atf_check -o inline:"test1\n" grep -L -e "D" test1
atf_check -o empty grep -q -e "B" test1
atf_check -o empty grep -q -B 1 -e "B" test1
@ -777,6 +837,8 @@ atf_init_test_cases()
atf_add_test_case egrep_empty_invalid
atf_add_test_case zerolen
atf_add_test_case wflag_emptypat
atf_add_test_case xflag_emptypat
atf_add_test_case xflag_emptypat_plus
atf_add_test_case excessive_matches
atf_add_test_case wv_combo_break
atf_add_test_case fgrep_sanity

View File

@ -194,43 +194,115 @@ process_file_actions(const posix_spawn_file_actions_t fa)
return (0);
}
struct posix_spawn_args {
const char *path;
const posix_spawn_file_actions_t *fa;
const posix_spawnattr_t *sa;
char * const * argv;
char * const * envp;
int use_env_path;
int error;
};
#if defined(__i386__) || defined(__amd64__)
#define _RFORK_THREAD_STACK_SIZE 4096
#endif
static int
_posix_spawn_thr(void *data)
{
struct posix_spawn_args *psa;
char * const *envp;
psa = data;
if (psa->sa != NULL) {
psa->error = process_spawnattr(*psa->sa);
if (psa->error)
_exit(127);
}
if (psa->fa != NULL) {
psa->error = process_file_actions(*psa->fa);
if (psa->error)
_exit(127);
}
envp = psa->envp != NULL ? psa->envp : environ;
if (psa->use_env_path)
_execvpe(psa->path, psa->argv, envp);
else
_execve(psa->path, psa->argv, envp);
psa->error = errno;
/* This is called in such a way that it must not exit. */
_exit(127);
}
static int
do_posix_spawn(pid_t *pid, const char *path,
const posix_spawn_file_actions_t *fa,
const posix_spawnattr_t *sa,
char * const argv[], char * const envp[], int use_env_path)
{
struct posix_spawn_args psa;
pid_t p;
volatile int error = 0;
#ifdef _RFORK_THREAD_STACK_SIZE
char *stack;
p = vfork();
switch (p) {
case -1:
return (errno);
case 0:
if (sa != NULL) {
error = process_spawnattr(*sa);
if (error)
_exit(127);
}
if (fa != NULL) {
error = process_file_actions(*fa);
if (error)
_exit(127);
}
if (use_env_path)
_execvpe(path, argv, envp != NULL ? envp : environ);
else
_execve(path, argv, envp != NULL ? envp : environ);
error = errno;
_exit(127);
default:
if (error != 0)
_waitpid(p, NULL, WNOHANG);
else if (pid != NULL)
*pid = p;
return (error);
stack = malloc(_RFORK_THREAD_STACK_SIZE);
if (stack == NULL)
return (ENOMEM);
#endif
psa.path = path;
psa.fa = fa;
psa.sa = sa;
psa.argv = argv;
psa.envp = envp;
psa.use_env_path = use_env_path;
psa.error = 0;
/*
* Passing RFSPAWN to rfork(2) gives us effectively a vfork that drops
* non-ignored signal handlers. We'll fall back to the slightly less
* ideal vfork(2) if we get an EINVAL from rfork -- this should only
* happen with newer libc on older kernel that doesn't accept
* RFSPAWN.
*/
#ifdef _RFORK_THREAD_STACK_SIZE
/*
* x86 stores the return address on the stack, so rfork(2) cannot work
* as-is because the child would clobber the return address om the
* parent. Because of this, we must use rfork_thread instead while
* almost every other arch stores the return address in a register.
*/
p = rfork_thread(RFSPAWN, stack + _RFORK_THREAD_STACK_SIZE,
_posix_spawn_thr, &psa);
free(stack);
#else
p = rfork(RFSPAWN);
if (p == 0)
/* _posix_spawn_thr does not return */
_posix_spawn_thr(&psa);
#endif
/*
* The above block should leave us in a state where we've either
* succeeded and we're ready to process the results, or we need to
* fallback to vfork() if the kernel didn't like RFSPAWN.
*/
if (p == -1 && errno == EINVAL) {
p = vfork();
if (p == 0)
/* _posix_spawn_thr does not return */
_posix_spawn_thr(&psa);
}
if (p == -1)
return (errno);
if (psa.error != 0)
/* Failed; ready to reap */
_waitpid(p, NULL, WNOHANG);
else if (pid != NULL)
/* exec succeeded */
*pid = p;
return (psa.error);
}
int

View File

@ -5,7 +5,6 @@ MDSRCS+= \
bcopy.S \
bzero.S \
ffs.S \
memchr.S \
memcmp.S \
memcpy.S \
memmove.S \

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 1993 Winning Strategies, Inc.
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Winning Strategies, Inc.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/*
* memchr (b, c, len)
* locates the first occurrence of c in string b.
*
* Written by:
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
*/
ENTRY(memchr)
pushl %edi
movl 8(%esp),%edi /* string address */
movl 12(%esp),%eax /* set character to search for */
movl 16(%esp),%ecx /* set length of search */
testl %esp,%esp /* clear Z flag, for len == 0 */
cld /* set search forward */
repne /* search! */
scasb
jnz L1 /* scan failed, return null */
leal -1(%edi),%eax /* adjust result of scan */
popl %edi
ret
.align 2,0x90
L1: xorl %eax,%eax
popl %edi
ret
END(memchr)
.section .note.GNU-stack,"",%progbits

View File

@ -391,6 +391,7 @@ __pid_t __sys_wait6(enum idtype, __id_t, int *, int,
struct __wrusage *, struct __siginfo *);
__ssize_t __sys_write(int, const void *, __size_t);
__ssize_t __sys_writev(int, const struct iovec *, int);
int __sys_shm_open2(const char *, int, __mode_t, int, const char *);
int __libc_sigaction(int, const struct sigaction *,
struct sigaction *) __hidden;

View File

@ -1068,7 +1068,7 @@ print(struct match *m,
fprintf(d, " %s", pchar(ch));
for (i = 0; i < g->nstates; i++)
if (ISSET(st, i)) {
fprintf(d, "%s%d", (first) ? "\t" : ", ", i);
fprintf(d, "%s%lu", (first) ? "\t" : ", ", i);
first = 0;
}
fprintf(d, "\n");

View File

@ -196,12 +196,6 @@ static char nuls[10]; /* place to point scanner in event of error */
#define THERETHERE() (p->slen - 2)
#define DROP(n) (p->slen -= (n))
#ifndef NDEBUG
static int never = 0; /* for use in asserts; shuts lint up */
#else
#define never 0 /* some <assert.h>s have bugs too */
#endif
/* Macro used by computejump()/computematchjump() */
#define MIN(a,b) ((a)<(b)?(a):(b))

View File

@ -46,6 +46,7 @@ PSEUDO+= _getdirentries.o
SRCS+= brk.c
SRCS+= pipe.c
SRCS+= shm_open.c
SRCS+= vadvise.c
SRCS+= compat-stub.c
@ -475,7 +476,9 @@ MLINKS+=setuid.2 setegid.2 \
setuid.2 seteuid.2 \
setuid.2 setgid.2
MLINKS+=shmat.2 shmdt.2
MLINKS+=shm_open.2 shm_unlink.2
MLINKS+=shm_open.2 memfd_create.3 \
shm_open.2 shm_unlink.2 \
shm_open.2 shm_rename.2
MLINKS+=sigwaitinfo.2 sigtimedwait.2
MLINKS+=stat.2 fstat.2 \
stat.2 fstatat.2 \

View File

@ -409,6 +409,8 @@ FBSD_1.6 {
fhreadlink;
getfhat;
funlinkat;
memfd_create;
shm_rename;
};
FBSDprivate_1.0 {

View File

@ -28,7 +28,7 @@
.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
.\" $FreeBSD$
.\"
.Dd Nov 15, 2018
.Dd September 4, 2019
.Dt FCNTL 2
.Os
.Sh NAME
@ -180,6 +180,11 @@ is non-zero.
A zero value in
.Fa arg
turns off read ahead.
.It Dv F_ADD_SEALS
Add seals to the file as described below, if the underlying filesystem supports
seals.
.It Dv F_GET_SEALS
Get seals associated with the file, if the underlying filesystem supports seals.
.El
.Pp
The flags for the
@ -217,6 +222,37 @@ when I/O is possible, e.g.,
upon availability of data to be read.
.El
.Pp
The seals that may be applied with
.Dv F_ADD_SEALS
are as follows:
.Bl -tag -width F_SEAL_SHRINK
.It Dv F_SEAL_SEAL
Prevent any further seals from being applied to the file.
.It Dv F_SEAL_SHRINK
Prevent the file from being shrunk with
.Xr ftruncate 2 .
.It Dv F_SEAL_GROW
Prevent the file from being enlarged with
.Xr ftruncate 2 .
.It Dv F_SEAL_WRITE
Prevent any further
.Xr write 2
calls to the file.
Any writes in progress will finish before
.Fn fcntl
returns.
If any writeable mappings exist, F_ADD_SEALS will fail and return
.Dv EBUSY .
.El
.Pp
Seals are on a per-inode basis and require support by the underlying filesystem.
If the underlying filesystem does not support seals,
.Dv F_ADD_SEALS
and
.Dv F_GET_SEALS
will fail and return
.Dv EINVAL .
.Pp
Several commands are available for doing advisory file locking;
they all operate on the following structure:
.Bd -literal
@ -528,6 +564,14 @@ is an exclusive lock
and
.Fa fd
is not a valid file descriptor open for writing.
.It Bq Er EBUSY
The argument
.Fa cmd
is
.Dv F_ADD_SEALS ,
attempting to set
.Dv F_SEAL_WRITE ,
and writeable mappings of the file exist.
.It Bq Er EDEADLK
The argument
.Fa cmd
@ -565,6 +609,14 @@ points is not valid.
.Pp
The argument
.Fa cmd
is
.Dv F_ADD_SEALS
or
.Dv F_GET_SEALS ,
and the underlying filesystem does not support sealing.
.Pp
The argument
.Fa cmd
is invalid.
.It Bq Er EMFILE
The argument
@ -624,6 +676,15 @@ is
and
the process ID or process group given as an argument is in a
different session than the caller.
.Pp
The
.Fa cmd
argument
is
.Dv F_ADD_SEALS
and the
.Dv F_SEAL_SEAL
seal has already been set.
.It Bq Er ESRCH
The
.Fa cmd

View File

@ -28,7 +28,7 @@
.\" @(#)mount.2 8.3 (Berkeley) 5/24/95
.\" $FreeBSD$
.\"
.Dd December 1, 2017
.Dd August 28, 2019
.Dt MOUNT 2
.Os
.Sh NAME
@ -157,6 +157,10 @@ mount even if some files are open for writing.
Disable read clustering.
.It Dv MNT_NOCLUSTERW
Disable write clustering.
.It Dv MNT_NOCOVER
Do not mount over the root of another mount point.
.It Dv MNT_EMPTYDIR
Require an empty directory for the mount point directory.
.El
.Pp
The flag
@ -260,6 +264,11 @@ is not a directory.
.It Bq Er EBUSY
Another process currently holds a reference to
.Fa dir .
.It Bq Er EBUSY
The
.Dv MNT_NOCOVER
option was given, and the requested mount point
is already the root of another mount point.
.It Bq Er EFAULT
The
.Fa dir
@ -280,6 +289,11 @@ The
.Fa fspec
argument
is not a block device.
.It Bq Er ENOTEMPTY
The
.Dv MNT_EMPTYDIR
option was specified, and the requested mount point
is not an empty directory.
.It Bq Er ENXIO
The major device number of
.Fa fspec

View File

@ -5,7 +5,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 12, 2011
.Dd September 25, 2019
.Dt RFORK 2
.Os
.Sh NAME
@ -34,7 +34,9 @@ and open files.
The
.Fa flags
argument
is the logical OR of some subset of:
is either
.Dv RFSPAWN
or the logical OR of some subset of:
.Bl -tag -width ".Dv RFLINUXTHPN"
.It Dv RFPROC
If set a new process is created; otherwise changes affect the
@ -105,6 +107,17 @@ open until either they are explicitly closed
or all processes sharing the table exit.
.Pp
If
.Dv RFSPAWN
is passed,
.Nm
will use
.Xr vfork 2
semantics but reset all signal actions in the child to default.
This flag is used by the
.Xr posix_spawn 3
implementation in libc.
.Pp
If
.Dv RFPROC
is set, the
value returned in the parent process

View File

@ -28,11 +28,11 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 20, 2017
.Dd September 26, 2019
.Dt SHM_OPEN 2
.Os
.Sh NAME
.Nm shm_open , shm_unlink
.Nm memfd_create , shm_open , shm_rename, shm_unlink
.Nd "shared memory object operations"
.Sh LIBRARY
.Lb libc
@ -41,8 +41,12 @@
.In sys/mman.h
.In fcntl.h
.Ft int
.Fn memfd_create "const char *name" "unsigned int flags"
.Ft int
.Fn shm_open "const char *path" "int flags" "mode_t mode"
.Ft int
.Fn shm_rename "const char *path_from" "const char *path_to" "int flags"
.Ft int
.Fn shm_unlink "const char *path"
.Sh DESCRIPTION
The
@ -110,8 +114,9 @@ see
and
.Xr fcntl 2 .
.Pp
As a FreeBSD extension,
the constant
As a
.Fx
extension, the constant
.Dv SHM_ANON
may be used for the
.Fa path
@ -120,7 +125,9 @@ argument to
In this case, an anonymous, unnamed shared memory object is created.
Since the object has no name,
it cannot be removed via a subsequent call to
.Fn shm_unlink .
.Fn shm_unlink ,
or moved with a call to
.Fn shm_rename .
Instead,
the shared memory object will be garbage collected when the last reference to
the shared memory object is removed.
@ -136,23 +143,103 @@ will fail with
All other flags are ignored.
.Pp
The
.Fn shm_rename
system call atomically removes a shared memory object named
.Fa path_from
and relinks it at
.Fa path_to .
If another object is already linked at
.Fa path_to ,
that object will be unlinked, unless one of the following flags are provided:
.Bl -tag -offset indent -width Er
.It Er SHM_RENAME_EXCHANGE
Atomically exchange the shms at
.Fa path_from
and
.Fa path_to .
.It Er SHM_RENAME_NOREPLACE
Return an error if an shm exists at
.Fa path_to ,
rather than unlinking it.
.El
.Fn shm_rename
is also a
.Fx
extension.
.Pp
The
.Fn shm_unlink
system call removes a shared memory object named
.Fa path .
.Pp
The
.Fn memfd_create
function creates an anonymous shared memory object, identical to that created
by
.Fn shm_open
when
.Dv SHM_ANON
is specified.
Newly created objects start off with a size of zero.
The size of the new object must be adjusted via
.Xr ftruncate 2 .
.Pp
The
.Fa name
argument must not be
.Dv NULL ,
but it may be an empty string.
The length of the
.Fa name
argument may not exceed
.Dv NAME_MAX
minus six characters for the prefix
.Dq memfd: ,
which will be prepended.
The
.Fa name
argument is intended solely for debugging purposes and will never be used by the
kernel to identify a memfd.
Names are therefore not required to be unique.
.Pp
The following
.Fa flags
may be specified to
.Fn memfd_create :
.Bl -tag -width MFD_ALLOW_SEALING
.It Dv MFD_CLOEXEC
Set
.Dv FD_CLOEXEC
on the resulting file descriptor.
.It Dv MFD_ALLOW_SEALING
Allow adding seals to the resulting file descriptor using the
.Dv F_ADD_SEALS
.Xr fcntl 2
command.
.It Dv MFD_HUGETLB
This flag is currently unsupported.
.El
.Sh RETURN VALUES
If successful,
.Fn memfd_create
and
.Fn shm_open
returns a non-negative integer,
both return a non-negative integer,
and
.Fn shm_rename
and
.Fn shm_unlink
returns zero.
Both functions return -1 on failure, and set
return zero.
All functions return -1 on failure, and set
.Va errno
to indicate the error.
.Sh COMPATIBILITY
The
.Fa path
argument does not necessarily represent a pathname (although it does in
.Fa path ,
.Fa path_from ,
and
.Fa path_to
arguments do not necessarily represent a pathname (although they do in
most other implementations).
Two processes opening the same
.Fa path
@ -220,6 +307,33 @@ This example fails without the call to
errx(EX_IOERR, "%s: pwrite length mismatch", __func__);
.Ed
.Sh ERRORS
.Fn memfd_create
fails with these error codes for these conditions:
.Bl -tag -width Er
.It Bq Er EBADF
The
.Fa name
argument was NULL.
.It Bq Er EINVAL
The
.Fa name
argument was too long.
.Pp
An invalid or unsupported flag was included in
.Fa flags .
.It Bq Er EMFILE
The process has already reached its limit for open file descriptors.
.It Bq Er ENFILE
The system file table is full.
.It Bq Er ENOSYS
In
.Fa memfd_create ,
.Dv MFD_HUGETLB
was specified in
.Fa flags ,
and this system does not support forced hugetlb mappings.
.El
.Pp
.Fn shm_open
fails with these error codes for these conditions:
.Bl -tag -width Er
@ -246,7 +360,7 @@ The
.Fa path
argument points outside the process' allocated address space.
.It Bq Er ENAMETOOLONG
The entire pathname exceeded 1023 characters.
The entire pathname exceeds 1023 characters.
.It Bq Er EINVAL
The
.Fa path
@ -265,6 +379,31 @@ are specified and the named shared memory object does exist.
The required permissions (for reading or reading and writing) are denied.
.El
.Pp
The following errors are defined for
.Fn shm_rename :
.Bl -tag -width Er
.It Bq Er EFAULT
The
.Fa path_from
or
.Fa path_to
argument points outside the process' allocated address space.
.It Bq Er ENAMETOOLONG
The entire pathname exceeds 1023 characters.
.It Bq Er ENOENT
The shared memory object at
.Fa path_from
does not exist.
.It Bq Er EACCES
The required permissions are denied.
.It Bq Er EEXIST
An shm exists at
.Fa path_to ,
and the
.Dv SHM_RENAME_NOREPLACE
flag was provided.
.El
.Pp
.Fn shm_unlink
fails with these error codes for these conditions:
.Bl -tag -width Er
@ -273,7 +412,7 @@ The
.Fa path
argument points outside the process' allocated address space.
.It Bq Er ENAMETOOLONG
The entire pathname exceeded 1023 characters.
The entire pathname exceeds 1023 characters.
.It Bq Er ENOENT
The named shared memory object does not exist.
.It Bq Er EACCES
@ -290,6 +429,11 @@ requires write permission to the shared memory object.
.Xr sendfile 2
.Sh STANDARDS
The
.Fn memfd_create
function is expected to be compatible with the Linux system call of the same
name.
.Pp
The
.Fn shm_open
and
.Fn shm_unlink
@ -297,6 +441,11 @@ functions are believed to conform to
.St -p1003.1b-93 .
.Sh HISTORY
The
.Fn memfd_create
function appeared in
.Fx 13.0 .
.Pp
The
.Fn shm_open
and
.Fn shm_unlink
@ -305,9 +454,19 @@ functions first appeared in
The functions were reimplemented as system calls using shared memory objects
directly rather than files in
.Fx 8.0 .
.Pp
.Fn shm_rename
first appeared in
.Fx 13.0
as a
.Fx
extension.
.Sh AUTHORS
.An Garrett A. Wollman Aq Mt wollman@FreeBSD.org
(C library support and this manual page)
.Pp
.An Matthew Dillon Aq Mt dillon@FreeBSD.org
.Pq Dv MAP_NOSYNC
.Pp
.An Matthew Bryan Aq Mt matthew.bryan@isilon.com
.Pq Dv shm_rename implementation

110
lib/libc/sys/shm_open.c Normal file
View File

@ -0,0 +1,110 @@
/*
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.org>
*
* 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(s), this list of conditions and the following disclaimer as
* the first lines of this file unmodified other than the possible
* addition of one or more copyright notices.
* 2. Redistributions in binary form must reproduce the above copyright
* notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "libc_private.h"
__weak_reference(shm_open, _shm_open);
__weak_reference(shm_open, __sys_shm_open);
#define SHM_OPEN2_OSREL 1300048
#define MEMFD_NAME_PREFIX "memfd:"
int
shm_open(const char *path, int flags, mode_t mode)
{
if (__getosreldate() >= SHM_OPEN2_OSREL)
return (__sys_shm_open2(path, flags | O_CLOEXEC, mode, 0,
NULL));
/*
* Fallback to shm_open(2) on older kernels. The kernel will enforce
* O_CLOEXEC in this interface, unlike the newer shm_open2 which does
* not enforce it. The newer interface allows memfd_create(), for
* instance, to not have CLOEXEC on the returned fd.
*/
return (syscall(SYS_freebsd12_shm_open, path, flags, mode));
}
/*
* The path argument is passed to the kernel, but the kernel doesn't currently
* do anything with it. Linux exposes it in linprocfs for debugging purposes
* only, but our kernel currently will not do the same.
*/
int
memfd_create(const char *name, unsigned int flags)
{
char memfd_name[NAME_MAX + 1];
size_t namelen;
int oflags, shmflags;
if (name == NULL)
return (EBADF);
namelen = strlen(name);
if (namelen + sizeof(MEMFD_NAME_PREFIX) - 1 > NAME_MAX)
return (EINVAL);
if ((flags & ~(MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB |
MFD_HUGE_MASK)) != 0)
return (EINVAL);
/* HUGETLB set with no size specified. */
if ((flags & MFD_HUGETLB) != 0 && (flags & MFD_HUGE_MASK) == 0)
return (EINVAL);
/* Size specified but no HUGETLB. */
if ((flags & MFD_HUGE_MASK) != 0 && (flags & MFD_HUGETLB) == 0)
return (EINVAL);
/* We don't actually support HUGETLB. */
if ((flags & MFD_HUGETLB) != 0)
return (ENOSYS);
/* We've already validated that we're sufficiently sized. */
snprintf(memfd_name, NAME_MAX + 1, "%s%s", MEMFD_NAME_PREFIX, name);
oflags = O_RDWR;
shmflags = 0;
if ((flags & MFD_CLOEXEC) != 0)
oflags |= O_CLOEXEC;
if ((flags & MFD_ALLOW_SEALING) != 0)
shmflags |= SHM_ALLOW_SEALING;
return (__sys_shm_open2(SHM_ANON, oflags, 0, shmflags, memfd_name));
}

View File

@ -67,6 +67,7 @@ __SCCSID("@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93");
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <nlist.h>
#include <kvm.h>
@ -130,13 +131,16 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
struct proc pproc;
struct sysentvec sysent;
char svname[KI_EMULNAMELEN];
struct thread *td = NULL;
bool first_thread;
kp = &kinfo_proc;
kp->ki_structsize = sizeof(kinfo_proc);
/*
* Loop on the processes. this is completely broken because we need to be
* able to loop on the threads and merge the ones that are the same process some how.
* Loop on the processes, then threads within the process if requested.
*/
if (what == KERN_PROC_ALL)
what |= KERN_PROC_INC_THREAD;
for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) {
memset(kp, 0, sizeof *kp);
if (KREAD(kd, (u_long)p, &proc)) {
@ -145,15 +149,6 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
}
if (proc.p_state == PRS_NEW)
continue;
if (proc.p_state != PRS_ZOMBIE) {
if (KREAD(kd, (u_long)TAILQ_FIRST(&proc.p_threads),
&mtd)) {
_kvm_err(kd, kd->program,
"can't read thread at %p",
TAILQ_FIRST(&proc.p_threads));
return (-1);
}
}
if (KREAD(kd, (u_long)proc.p_ucred, &ucred) == 0) {
kp->ki_ruid = ucred.cr_ruid;
kp->ki_svuid = ucred.cr_svuid;
@ -222,6 +217,7 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
kp->ki_addr = 0; /* XXX uarea */
/* kp->ki_kstack = proc.p_thread.td_kstack; XXXKSE */
kp->ki_args = proc.p_args;
kp->ki_numthreads = proc.p_numthreads;
kp->ki_tracep = proc.p_tracevp;
kp->ki_textvp = proc.p_textvp;
kp->ki_fd = proc.p_fd;
@ -285,9 +281,6 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
kp->ki_sid = sess.s_sid;
(void)memcpy(kp->ki_login, sess.s_login,
sizeof(kp->ki_login));
kp->ki_kiflag = sess.s_ttyvp ? KI_CTTY : 0;
if (sess.s_leader == p)
kp->ki_kiflag |= KI_SLEADER;
if ((proc.p_flag & P_CONTROLT) && sess.s_ttyp != NULL) {
if (KREAD(kd, (u_long)sess.s_ttyp, &tty)) {
_kvm_err(kd, kd->program,
@ -330,9 +323,6 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
nopgrp:
kp->ki_tdev = NODEV;
}
if ((proc.p_state != PRS_ZOMBIE) && mtd.td_wmesg)
(void)kvm_read(kd, (u_long)mtd.td_wmesg,
kp->ki_wmesg, WMESGLEN);
(void)kvm_read(kd, (u_long)proc.p_vmspace,
(char *)&vmspace, sizeof(vmspace));
@ -374,85 +364,127 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
sizeof(svname));
if (svname[0] != 0)
strlcpy(kp->ki_emul, svname, KI_EMULNAMELEN);
if ((proc.p_state != PRS_ZOMBIE) &&
(mtd.td_blocked != 0)) {
kp->ki_kiflag |= KI_LOCKBLOCK;
if (mtd.td_lockname)
(void)kvm_read(kd,
(u_long)mtd.td_lockname,
kp->ki_lockname, LOCKNAMELEN);
kp->ki_lockname[LOCKNAMELEN] = 0;
}
kp->ki_runtime = cputick2usec(proc.p_rux.rux_runtime);
kp->ki_pid = proc.p_pid;
kp->ki_siglist = proc.p_siglist;
SIGSETOR(kp->ki_siglist, mtd.td_siglist);
kp->ki_sigmask = mtd.td_sigmask;
kp->ki_xstat = KW_EXITCODE(proc.p_xexit, proc.p_xsig);
kp->ki_acflag = proc.p_acflag;
kp->ki_lock = proc.p_lock;
if (proc.p_state != PRS_ZOMBIE) {
kp->ki_swtime = (ticks - proc.p_swtick) / hz;
kp->ki_flag = proc.p_flag;
kp->ki_sflag = 0;
kp->ki_nice = proc.p_nice;
kp->ki_traceflag = proc.p_traceflag;
if (proc.p_state == PRS_NORMAL) {
if (TD_ON_RUNQ(&mtd) ||
TD_CAN_RUN(&mtd) ||
TD_IS_RUNNING(&mtd)) {
kp->ki_stat = SRUN;
} else if (mtd.td_state ==
TDS_INHIBITED) {
if (P_SHOULDSTOP(&proc)) {
kp->ki_stat = SSTOP;
} else if (
TD_IS_SLEEPING(&mtd)) {
kp->ki_stat = SSLEEP;
} else if (TD_ON_LOCK(&mtd)) {
kp->ki_stat = SLOCK;
} else {
kp->ki_stat = SWAIT;
}
}
} else {
kp->ki_stat = SIDL;
}
/* Stuff from the thread */
kp->ki_pri.pri_level = mtd.td_priority;
kp->ki_pri.pri_native = mtd.td_base_pri;
kp->ki_lastcpu = mtd.td_lastcpu;
kp->ki_wchan = mtd.td_wchan;
kp->ki_oncpu = mtd.td_oncpu;
if (mtd.td_name[0] != '\0')
strlcpy(kp->ki_tdname, mtd.td_name, sizeof(kp->ki_tdname));
kp->ki_pctcpu = 0;
kp->ki_rqindex = 0;
/*
* Note: legacy fields; wraps at NO_CPU_OLD or the
* old max CPU value as appropriate
*/
if (mtd.td_lastcpu == NOCPU)
kp->ki_lastcpu_old = NOCPU_OLD;
else if (mtd.td_lastcpu > MAXCPU_OLD)
kp->ki_lastcpu_old = MAXCPU_OLD;
else
kp->ki_lastcpu_old = mtd.td_lastcpu;
if (mtd.td_oncpu == NOCPU)
kp->ki_oncpu_old = NOCPU_OLD;
else if (mtd.td_oncpu > MAXCPU_OLD)
kp->ki_oncpu_old = MAXCPU_OLD;
else
kp->ki_oncpu_old = mtd.td_oncpu;
} else {
kp->ki_stat = SZOMB;
}
kp->ki_tdev_freebsd11 = kp->ki_tdev; /* truncate */
bcopy(&kinfo_proc, bp, sizeof(kinfo_proc));
++bp;
++cnt;
/* Per-thread items; iterate as appropriate. */
td = TAILQ_FIRST(&proc.p_threads);
for (first_thread = true; cnt < maxcnt && td != NULL &&
(first_thread || (what & KERN_PROC_INC_THREAD));
first_thread = false) {
if (proc.p_state != PRS_ZOMBIE) {
if (KREAD(kd, (u_long)td, &mtd)) {
_kvm_err(kd, kd->program,
"can't read thread at %p", td);
return (-1);
}
if (what & KERN_PROC_INC_THREAD)
td = TAILQ_NEXT(&mtd, td_plist);
} else
td = NULL;
if ((proc.p_state != PRS_ZOMBIE) && mtd.td_wmesg)
(void)kvm_read(kd, (u_long)mtd.td_wmesg,
kp->ki_wmesg, WMESGLEN);
else
memset(kp->ki_wmesg, 0, WMESGLEN);
if (proc.p_pgrp == NULL) {
kp->ki_kiflag = 0;
} else {
kp->ki_kiflag = sess.s_ttyvp ? KI_CTTY : 0;
if (sess.s_leader == p)
kp->ki_kiflag |= KI_SLEADER;
}
if ((proc.p_state != PRS_ZOMBIE) &&
(mtd.td_blocked != 0)) {
kp->ki_kiflag |= KI_LOCKBLOCK;
if (mtd.td_lockname)
(void)kvm_read(kd,
(u_long)mtd.td_lockname,
kp->ki_lockname, LOCKNAMELEN);
else
memset(kp->ki_lockname, 0,
LOCKNAMELEN);
kp->ki_lockname[LOCKNAMELEN] = 0;
} else
kp->ki_kiflag &= ~KI_LOCKBLOCK;
kp->ki_siglist = proc.p_siglist;
if (proc.p_state != PRS_ZOMBIE) {
SIGSETOR(kp->ki_siglist, mtd.td_siglist);
kp->ki_sigmask = mtd.td_sigmask;
kp->ki_swtime = (ticks - proc.p_swtick) / hz;
kp->ki_flag = proc.p_flag;
kp->ki_sflag = 0;
kp->ki_nice = proc.p_nice;
kp->ki_traceflag = proc.p_traceflag;
if (proc.p_state == PRS_NORMAL) {
if (TD_ON_RUNQ(&mtd) ||
TD_CAN_RUN(&mtd) ||
TD_IS_RUNNING(&mtd)) {
kp->ki_stat = SRUN;
} else if (mtd.td_state ==
TDS_INHIBITED) {
if (P_SHOULDSTOP(&proc)) {
kp->ki_stat = SSTOP;
} else if (
TD_IS_SLEEPING(&mtd)) {
kp->ki_stat = SSLEEP;
} else if (TD_ON_LOCK(&mtd)) {
kp->ki_stat = SLOCK;
} else {
kp->ki_stat = SWAIT;
}
}
} else {
kp->ki_stat = SIDL;
}
/* Stuff from the thread */
kp->ki_pri.pri_level = mtd.td_priority;
kp->ki_pri.pri_native = mtd.td_base_pri;
kp->ki_lastcpu = mtd.td_lastcpu;
kp->ki_wchan = mtd.td_wchan;
kp->ki_oncpu = mtd.td_oncpu;
if (mtd.td_name[0] != '\0')
strlcpy(kp->ki_tdname, mtd.td_name,
sizeof(kp->ki_tdname));
else
memset(kp->ki_tdname, 0,
sizeof(kp->ki_tdname));
kp->ki_pctcpu = 0;
kp->ki_rqindex = 0;
/*
* Note: legacy fields; wraps at NO_CPU_OLD
* or the old max CPU value as appropriate
*/
if (mtd.td_lastcpu == NOCPU)
kp->ki_lastcpu_old = NOCPU_OLD;
else if (mtd.td_lastcpu > MAXCPU_OLD)
kp->ki_lastcpu_old = MAXCPU_OLD;
else
kp->ki_lastcpu_old = mtd.td_lastcpu;
if (mtd.td_oncpu == NOCPU)
kp->ki_oncpu_old = NOCPU_OLD;
else if (mtd.td_oncpu > MAXCPU_OLD)
kp->ki_oncpu_old = MAXCPU_OLD;
else
kp->ki_oncpu_old = mtd.td_oncpu;
kp->ki_tid = mtd.td_tid;
} else {
memset(&kp->ki_sigmask, 0,
sizeof(kp->ki_sigmask));
kp->ki_stat = SZOMB;
kp->ki_tid = 0;
}
bcopy(&kinfo_proc, bp, sizeof(kinfo_proc));
++bp;
++cnt;
}
}
return (cnt);
}
@ -466,7 +498,7 @@ kvm_deadprocs(kvm_t *kd, int what, int arg, u_long a_allproc,
u_long a_zombproc, int maxcnt)
{
struct kinfo_proc *bp = kd->procbase;
int acnt, zcnt;
int acnt, zcnt = 0;
struct proc *p;
if (KREAD(kd, a_allproc, &p)) {
@ -477,13 +509,15 @@ kvm_deadprocs(kvm_t *kd, int what, int arg, u_long a_allproc,
if (acnt < 0)
return (acnt);
if (KREAD(kd, a_zombproc, &p)) {
_kvm_err(kd, kd->program, "cannot read zombproc");
return (-1);
if (a_zombproc != 0) {
if (KREAD(kd, a_zombproc, &p)) {
_kvm_err(kd, kd->program, "cannot read zombproc");
return (-1);
}
zcnt = kvm_proclist(kd, what, arg, p, bp + acnt, maxcnt - acnt);
if (zcnt < 0)
zcnt = 0;
}
zcnt = kvm_proclist(kd, what, arg, p, bp + acnt, maxcnt - acnt);
if (zcnt < 0)
zcnt = 0;
return (acnt + zcnt);
}
@ -568,15 +602,18 @@ kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
liveout:
nprocs = size == 0 ? 0 : size / kd->procbase->ki_structsize;
} else {
struct nlist nl[7], *p;
struct nlist nl[6], *p;
struct nlist nlz[2];
nl[0].n_name = "_nprocs";
nl[1].n_name = "_allproc";
nl[2].n_name = "_zombproc";
nl[3].n_name = "_ticks";
nl[4].n_name = "_hz";
nl[5].n_name = "_cpu_tick_frequency";
nl[6].n_name = 0;
nl[2].n_name = "_ticks";
nl[3].n_name = "_hz";
nl[4].n_name = "_cpu_tick_frequency";
nl[5].n_name = 0;
nlz[0].n_name = "_zombproc";
nlz[1].n_name = 0;
if (!kd->arch->ka_native(kd)) {
_kvm_err(kd, kd->program,
@ -591,19 +628,27 @@ kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
"%s: no such symbol", p->n_name);
return (0);
}
(void) kvm_nlist(kd, nlz); /* attempt to get zombproc */
if (KREAD(kd, nl[0].n_value, &nprocs)) {
_kvm_err(kd, kd->program, "can't read nprocs");
return (0);
}
if (KREAD(kd, nl[3].n_value, &ticks)) {
/*
* If returning all threads, we don't know how many that
* might be. Presume that there are, on average, no more
* than 10 threads per process.
*/
if (op == KERN_PROC_ALL || (op & KERN_PROC_INC_THREAD))
nprocs *= 10; /* XXX */
if (KREAD(kd, nl[2].n_value, &ticks)) {
_kvm_err(kd, kd->program, "can't read ticks");
return (0);
}
if (KREAD(kd, nl[4].n_value, &hz)) {
if (KREAD(kd, nl[3].n_value, &hz)) {
_kvm_err(kd, kd->program, "can't read hz");
return (0);
}
if (KREAD(kd, nl[5].n_value, &cpu_tick_frequency)) {
if (KREAD(kd, nl[4].n_value, &cpu_tick_frequency)) {
_kvm_err(kd, kd->program,
"can't read cpu_tick_frequency");
return (0);
@ -614,7 +659,7 @@ kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
return (0);
nprocs = kvm_deadprocs(kd, op, arg, nl[1].n_value,
nl[2].n_value, nprocs);
nlz[0].n_value, nprocs);
if (nprocs <= 0) {
_kvm_freeprocs(kd);
nprocs = 0;

View File

@ -1,6 +1,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
#
# Copyright (c) 2017 Kyle Evans <kevans@FreeBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions

View File

@ -474,7 +474,11 @@ _thr_mutex_destroy(pthread_mutex_t *mutex)
if (m == THR_PSHARED_PTR) {
m1 = __thr_pshared_offpage(mutex, 0);
if (m1 != NULL) {
mutex_assert_not_owned(_get_curthread(), m1);
if ((uint32_t)m1->m_lock.m_owner !=
UMUTEX_RB_OWNERDEAD) {
mutex_assert_not_owned(
_get_curthread(), m1);
}
__thr_pshared_destroy(mutex);
}
*mutex = THR_MUTEX_DESTROYED;

View File

@ -145,9 +145,9 @@ __ieee754_exp(double x) /* default IEEE double exp */
/* x is now in primary range */
t = x*x;
if(k >= -1021)
INSERT_WORDS(twopk,0x3ff00000+(k<<20), 0);
INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20, 0);
else
INSERT_WORDS(twopk,0x3ff00000+((k+1000)<<20), 0);
INSERT_WORDS(twopk,((u_int32_t)(0x3ff+(k+1000)))<<20, 0);
c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
if(k==0) return one-((x*c)/(c-2.0)-x);
else y = one-((lo-(x*c)/(2.0-c))-hi);

View File

@ -83,9 +83,9 @@ __ieee754_expf(float x)
/* x is now in primary range */
t = x*x;
if(k >= -125)
SET_FLOAT_WORD(twopk,0x3f800000+(k<<23));
SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23);
else
SET_FLOAT_WORD(twopk,0x3f800000+((k+100)<<23));
SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+(k+100)))<<23);
c = x - t*(P1+t*P2);
if(k==0) return one-((x*c)/(c-(float)2.0)-x);
else y = one-((lo-(x*c)/((float)2.0-c))-hi);

View File

@ -188,7 +188,7 @@ expm1(double x)
e = hxs*((r1-t)/(6.0 - x*t));
if(k==0) return x - (x*e-hxs); /* c is 0 */
else {
INSERT_WORDS(twopk,0x3ff00000+(k<<20),0); /* 2^k */
INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20,0); /* 2^k */
e = (x*(e-c)-c);
e -= hxs;
if(k== -1) return 0.5*(x-e)-0.5;

View File

@ -94,7 +94,7 @@ expm1f(float x)
e = hxs*((r1-t)/((float)6.0 - x*t));
if(k==0) return x - (x*e-hxs); /* c is 0 */
else {
SET_FLOAT_WORD(twopk,0x3f800000+(k<<23)); /* 2^k */
SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23); /* 2^k */
e = (x*(e-c)-c);
e -= hxs;
if(k== -1) return (float)0.5*(x-e)-(float)0.5;

View File

@ -65,7 +65,8 @@ struct mntopt {
#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
#define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 }
#define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 }
/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
#define MOPT_AUTO { "auto", 0, 0, 0 }
@ -95,7 +96,9 @@ struct mntopt {
MOPT_ACLS, \
MOPT_NFS4ACLS, \
MOPT_AUTOMOUNTED, \
MOPT_UNTRUSTED
MOPT_UNTRUSTED, \
MOPT_NOCOVER, \
MOPT_EMPTYDIR
void getmntopts(const char *, const struct mntopt *, int *, int *);
void rmslashes(char *, char *);

View File

@ -28,7 +28,7 @@
.\" @(#)mount.8 8.8 (Berkeley) 6/16/94
.\" $FreeBSD$
.\"
.Dd March 22, 2017
.Dd August 28, 2019
.Dt MOUNT 8
.Os
.Sh NAME
@ -162,6 +162,8 @@ When used with the
.Fl u
flag, this is the same as specifying the options currently in effect for
the mounted file system.
.It Cm emptydir
Require that the mount point directory be empty.
.It Cm force
The same as
.Fl f ;
@ -237,6 +239,9 @@ flag.
Disable read clustering.
.It Cm noclusterw
Disable write clustering.
.It Cm nocover
Do not mount if the requested mount point is already
the root of a mount point.
.It Cm noexec
Do not allow execution of any binaries on the mounted file system.
This option is useful for a server that has file systems containing

View File

@ -119,6 +119,8 @@ static struct opt {
{ MNT_AUTOMOUNTED, "automounted" },
{ MNT_VERIFIED, "verified" },
{ MNT_UNTRUSTED, "untrusted" },
{ MNT_NOCOVER, "nocover" },
{ MNT_EMPTYDIR, "emptydir" },
{ 0, NULL }
};
@ -975,6 +977,8 @@ flags2opts(int flags)
if (flags & MNT_ACLS) res = catopt(res, "acls");
if (flags & MNT_NFS4ACLS) res = catopt(res, "nfsv4acls");
if (flags & MNT_UNTRUSTED) res = catopt(res, "untrusted");
if (flags & MNT_NOCOVER) res = catopt(res, "nocover");
if (flags & MNT_EMPTYDIR) res = catopt(res, "emptydir");
return (res);
}

View File

@ -143,9 +143,9 @@ perftest(const struct cmd *f, int argc, char *argv[])
if (arg_parse(argc, argv, f))
return;
if (opt.flags == NULL || opt.op == NULL)
if (opt.op == NULL)
arg_help(argc, argv, f);
if (strcmp(opt.flags, "refthread") == 0)
if (opt.flags != NULL && strcmp(opt.flags, "refthread") == 0)
io_test.flags |= NVME_TEST_FLAG_REFTHREAD;
if (opt.intr != NULL) {
if (strcmp(opt.intr, "bio") == 0 ||
@ -163,6 +163,7 @@ perftest(const struct cmd *f, int argc, char *argv[])
fprintf(stderr, "Bad number of threads %d\n", opt.threads);
arg_help(argc, argv, f);
}
io_test.num_threads = opt.threads;
if (strcasecmp(opt.op, "read") == 0)
io_test.opc = NVME_OPC_READ;
else if (strcasecmp(opt.op, "write") == 0)
@ -176,6 +177,7 @@ perftest(const struct cmd *f, int argc, char *argv[])
arg_help(argc, argv, f);
}
io_test.time = opt.time;
io_test.size = opt.size;
open_dev(opt.dev, &fd, 1, 1);
if (ioctl(fd, ioctl_cmd, &io_test) < 0)
err(1, "ioctl NVME_IO_TEST failed");

View File

@ -1028,8 +1028,8 @@ main(int argc, char *argv[])
err(1, "caph_enter_casper");
cap_rights_init(&rights_stdin);
if (cap_rights_limit(STDIN_FILENO, &rights_stdin) < 0)
err(1, "cap_rights_limit stdin");
if (caph_rights_limit(STDIN_FILENO, &rights_stdin) < 0)
err(1, "caph_rights_limit stdin");
if (caph_limit_stdout() < 0)
err(1, "caph_limit_stdout");
if (caph_limit_stderr() < 0)
@ -1037,10 +1037,10 @@ main(int argc, char *argv[])
cap_rights_init(&rights_srecv, CAP_RECV, CAP_EVENT, CAP_SETSOCKOPT);
if (caph_rights_limit(srecv, &rights_srecv) < 0)
err(1, "cap_rights_limit srecv");
err(1, "caph_rights_limit srecv");
cap_rights_init(&rights_ssend, CAP_SEND, CAP_SETSOCKOPT);
if (caph_rights_limit(ssend, &rights_ssend) < 0)
err(1, "cap_rights_limit ssend");
err(1, "caph_rights_limit ssend");
#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
if (sockbufsize) {
@ -1092,10 +1092,10 @@ main(int argc, char *argv[])
cap_rights_clear(&rights_srecv, CAP_SETSOCKOPT);
if (caph_rights_limit(srecv, &rights_srecv) < 0)
err(1, "cap_rights_limit srecv setsockopt");
err(1, "caph_rights_limit srecv setsockopt");
cap_rights_clear(&rights_ssend, CAP_SETSOCKOPT);
if (caph_rights_limit(ssend, &rights_ssend) < 0)
err(1, "cap_rights_limit ssend setsockopt");
err(1, "caph_rights_limit ssend setsockopt");
printf("PING6(%lu=40+8+%lu bytes) ", (unsigned long)(40 + pingerlen()),
(unsigned long)(pingerlen() - 8));

View File

@ -120,7 +120,7 @@ beforecheck:
# etc.
aftercheck:
@cd ${.CURDIR} && ${MAKE} clean
@chflags -R 0 "${DESTDIR}"
@test ! -e ${DESTDIR} || chflags -R 0 "${DESTDIR}"
@rm -Rf "${DESTDIR}"
.endif

View File

@ -343,6 +343,91 @@ efi_cons_probe(struct console *cp)
cp->c_flags |= C_PRESENTIN | C_PRESENTOUT;
}
static bool
color_name_to_teken(const char *name, int *val)
{
if (strcasecmp(name, "black") == 0) {
*val = TC_BLACK;
return (true);
}
if (strcasecmp(name, "red") == 0) {
*val = TC_RED;
return (true);
}
if (strcasecmp(name, "green") == 0) {
*val = TC_GREEN;
return (true);
}
if (strcasecmp(name, "brown") == 0) {
*val = TC_BROWN;
return (true);
}
if (strcasecmp(name, "blue") == 0) {
*val = TC_BLUE;
return (true);
}
if (strcasecmp(name, "magenta") == 0) {
*val = TC_MAGENTA;
return (true);
}
if (strcasecmp(name, "cyan") == 0) {
*val = TC_CYAN;
return (true);
}
if (strcasecmp(name, "white") == 0) {
*val = TC_WHITE;
return (true);
}
return (false);
}
static int
efi_set_colors(struct env_var *ev, int flags, const void *value)
{
int val = 0;
char buf[2];
const void *evalue;
const teken_attr_t *ap;
teken_attr_t a;
if (value == NULL)
return (CMD_OK);
if (color_name_to_teken(value, &val)) {
snprintf(buf, sizeof (buf), "%d", val);
evalue = buf;
} else {
char *end;
errno = 0;
val = (int)strtol(value, &end, 0);
if (errno != 0 || *end != '\0') {
printf("Allowed values are either ansi color name or "
"number from range [0-7].\n");
return (CMD_OK);
}
evalue = value;
}
ap = teken_get_defattr(&teken);
a = *ap;
if (strcmp(ev->ev_name, "teken.fg_color") == 0) {
/* is it already set? */
if (ap->ta_fgcolor == val)
return (CMD_OK);
a.ta_fgcolor = val;
}
if (strcmp(ev->ev_name, "teken.bg_color") == 0) {
/* is it already set? */
if (ap->ta_bgcolor == val)
return (CMD_OK);
a.ta_bgcolor = val;
}
env_setenv(ev->ev_name, flags | EV_NOHOOK, evalue, NULL, NULL);
teken_set_defattr(&teken, &a);
return (CMD_OK);
}
bool
efi_cons_update_mode(void)
{
@ -374,6 +459,13 @@ efi_cons_update_mode(void)
teken_set_winsize(&teken, &tp);
a = teken_get_defattr(&teken);
snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
env_setenv("teken.fg_color", EV_VOLATILE, env, efi_set_colors,
env_nounset);
snprintf(env, sizeof(env), "%d", a->ta_bgcolor);
env_setenv("teken.bg_color", EV_VOLATILE, env, efi_set_colors,
env_nounset);
for (int row = 0; row < rows; row++)
for (int col = 0; col < cols; col++) {
buffer[col + row * tp.tp_col].c = ' ';

View File

@ -397,7 +397,7 @@ also menu-infrastructure definitions
setenv
\ Assign third to ansi_caption[x][y]
kerncapbuf 0 s" @[1mK@[37mernel: " [char] @ escc! strcat
kerncapbuf 0 s" @[1mK@[mernel: " [char] @ escc! strcat
kernmenuidx @ [char] 0 = if
s" default/@[32m"
else
@ -405,7 +405,7 @@ also menu-infrastructure definitions
then
[char] @ escc! strcat
2over strcat
s" @[37m" [char] @ escc! strcat
s" @[m" [char] @ escc! strcat
kernidx @ kernmenuidx @ ansi_caption[x][y]
setenv

View File

@ -72,7 +72,7 @@ s" currdev" getenv dup 0> [if] drop 4 s" zfs:" compare 0= [if]
set mainmenu_caption[7]="Select Boot [E]nvironment..."
set mainmenu_command[7]="3 goto_menu"
set mainmenu_keycode[7]=101
set mainansi_caption[7]="Select Boot ^[1mE^[37mnvironment..."
set mainansi_caption[7]="Select Boot ^[1mE^[mnvironment..."
s" chain_disk" getenv? [if]
set mainmenu_caption[8]="Chain[L]oad ${chain_disk}"

View File

@ -569,6 +569,96 @@ vidc_probe(struct console *cp)
cp->c_flags |= C_PRESENTOUT;
}
static bool
color_name_to_teken(const char *name, int *val)
{
if (strcasecmp(name, "black") == 0) {
*val = TC_BLACK;
return (true);
}
if (strcasecmp(name, "red") == 0) {
*val = TC_RED;
return (true);
}
if (strcasecmp(name, "green") == 0) {
*val = TC_GREEN;
return (true);
}
if (strcasecmp(name, "brown") == 0) {
*val = TC_BROWN;
return (true);
}
if (strcasecmp(name, "blue") == 0) {
*val = TC_BLUE;
return (true);
}
if (strcasecmp(name, "magenta") == 0) {
*val = TC_MAGENTA;
return (true);
}
if (strcasecmp(name, "cyan") == 0) {
*val = TC_CYAN;
return (true);
}
if (strcasecmp(name, "white") == 0) {
*val = TC_WHITE;
return (true);
}
return (false);
}
static int
vidc_set_colors(struct env_var *ev, int flags, const void *value)
{
int val = 0;
char buf[2];
const void *evalue;
const teken_attr_t *ap;
teken_attr_t a;
if (value == NULL)
return (CMD_OK);
if (color_name_to_teken(value, &val)) {
snprintf(buf, sizeof (buf), "%d", val);
evalue = buf;
} else {
char *end;
errno = 0;
val = (int)strtol(value, &end, 0);
if (errno != 0 || *end != '\0') {
printf("Allowed values are either ansi color name or "
"number from range [0-7].\n");
return (CMD_OK);
}
evalue = value;
}
ap = teken_get_defattr(&teken);
a = *ap;
if (strcmp(ev->ev_name, "teken.fg_color") == 0) {
/* is it already set? */
if (ap->ta_fgcolor == val)
return (CMD_OK);
a.ta_fgcolor = val;
}
if (strcmp(ev->ev_name, "teken.bg_color") == 0) {
/* is it already set? */
if (ap->ta_bgcolor == val)
return (CMD_OK);
a.ta_bgcolor = val;
}
/* Improve visibility */
if (a.ta_bgcolor == TC_WHITE)
a.ta_bgcolor |= TC_LIGHT;
env_setenv(ev->ev_name, flags | EV_NOHOOK, evalue, NULL, NULL);
teken_set_defattr(&teken, &a);
return (CMD_OK);
}
static int
vidc_init(int arg)
{
@ -603,15 +693,22 @@ vidc_init(int arg)
if (buffer == NULL)
return (1);
teken_init(&teken, &tf, NULL);
teken_set_winsize(&teken, &tp);
a = teken_get_defattr(&teken);
snprintf(env, sizeof (env), "%u", tp.tp_row);
setenv("LINES", env, 1);
snprintf(env, sizeof (env), "%u", tp.tp_col);
setenv("COLUMNS", env, 1);
teken_init(&teken, &tf, NULL);
teken_set_winsize(&teken, &tp);
a = teken_get_defattr(&teken);
snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
env_setenv("teken.fg_color", EV_VOLATILE, env, vidc_set_colors,
env_nounset);
snprintf(env, sizeof(env), "%d", a->ta_bgcolor);
env_setenv("teken.bg_color", EV_VOLATILE, env, vidc_set_colors,
env_nounset);
for (int row = 0; row < tp.tp_row; row++)
for (int col = 0; col < tp.tp_col; col++) {
buffer[col + row * tp.tp_col].c = ' ';

View File

@ -42,7 +42,7 @@ color.MAGENTA = 5
color.CYAN = 6
color.WHITE = 7
color.DEFAULT = 0
color.DEFAULT = 9
color.BRIGHT = 1
color.DIM = 2
@ -67,7 +67,7 @@ function color.resetfg()
if color.disabled then
return ''
end
return color.escapefg(color.WHITE)
return color.escapefg(color.DEFAULT)
end
function color.escapebg(color_value)
@ -81,7 +81,7 @@ function color.resetbg()
if color.disabled then
return ''
end
return color.escapebg(color.BLACK)
return color.escapebg(color.DEFAULT)
end
function color.escape(fg_color, bg_color, attribute)
@ -101,7 +101,7 @@ function color.default()
if color.disabled then
return ""
end
return color.escape(color.WHITE, color.BLACK, color.DEFAULT)
return color.escape(color.DEFAULT, color.DEFAULT)
end
function color.highlight(str)

View File

@ -2,7 +2,7 @@
-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
--
-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
-- Copyright (C) 2018 Kyle Evans <kevans@FreeBSD.org>
-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without

View File

@ -48,7 +48,7 @@ local beastie_color = {
" \\ / /\\",
" \027[36m______\027[31m( (_ / \\______/",
" \027[36m,' ,-----' |",
" `--{__________)\027[37m"
" `--{__________)\027[m"
}
drawer.addLogo("beastie", {

View File

@ -44,7 +44,7 @@ local orb_color = {
" -- \027[31;1m-.\027[31m",
" `:` \027[31;1m`:`",
" \027[31;1m.-- `--.",
" .---.....----.\027[37m"
" .---.....----.\027[m"
}
drawer.addLogo("orb", {

View File

@ -2,7 +2,7 @@
-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
--
-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
-- Copyright (C) 2018 Kyle Evans <kevans@FreeBSD.org>
-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
@ -47,10 +47,10 @@ local return_menu_entry = {
local function OnOff(str, value)
if value then
return str .. color.escapefg(color.GREEN) .. "On" ..
color.escapefg(color.WHITE)
color.resetfg()
else
return str .. color.escapefg(color.RED) .. "off" ..
color.escapefg(color.WHITE)
color.resetfg()
end
end

View File

@ -2,7 +2,7 @@
-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
--
-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
-- Copyright (C) 2018 Kyle Evans <kevans@FreeBSD.org>
-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without

View File

@ -74,7 +74,7 @@ efi_destroy_1t1_map(void)
if (obj_1t1_pt != NULL) {
VM_OBJECT_RLOCK(obj_1t1_pt);
TAILQ_FOREACH(m, &obj_1t1_pt->memq, listq)
m->wire_count = VPRC_OBJREF;
m->ref_count = VPRC_OBJREF;
vm_wire_sub(obj_1t1_pt->resident_page_count);
VM_OBJECT_RUNLOCK(obj_1t1_pt);
vm_object_deallocate(obj_1t1_pt);

View File

@ -267,7 +267,6 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
*/
printf("kldload: unexpected R_COPY relocation\n");
return (-1);
break;
case R_X86_64_GLOB_DAT: /* S */
case R_X86_64_JMP_SLOT: /* XXX need addend + offset */
@ -279,7 +278,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
break;
case R_X86_64_RELATIVE: /* B + A */
addr = relocbase + addend;
addr = elf_relocaddr(lf, relocbase + addend);
val = addr;
if (*where != val)
*where = val;

Some files were not shown because too many files have changed in this diff Show More