dragonfly.git
4 years agoRemove nextboot remains.
Sascha Wildner [Fri, 1 Nov 2019 11:39:29 +0000 (12:39 +0100)]
Remove nextboot remains.

While here, staticize reboot(8) a bit.

4 years agoRemove checknr(1) which stopped being useful a long time ago.
Sascha Wildner [Fri, 1 Nov 2019 10:24:18 +0000 (11:24 +0100)]
Remove checknr(1) which stopped being useful a long time ago.

It reports a ton of errors on pretty much any manual page, regardless
of macro dialect.

mandoc(1) (and groff) have much better checking capabilities.

4 years agolibtelnet: Use NULL for a pointer.
Sascha Wildner [Fri, 1 Nov 2019 10:06:41 +0000 (11:06 +0100)]
libtelnet: Use NULL for a pointer.

4 years agolibipfw3: Use NULL for a pointer.
Sascha Wildner [Fri, 1 Nov 2019 10:06:32 +0000 (11:06 +0100)]
libipfw3: Use NULL for a pointer.

4 years agorouted(8): Use NULL for a pointer.
Sascha Wildner [Fri, 1 Nov 2019 10:06:28 +0000 (11:06 +0100)]
routed(8): Use NULL for a pointer.

4 years agousr.sbin/fstyp: Fix warning on Linux distros
Tomohiro Kusumi [Thu, 31 Oct 2019 23:47:02 +0000 (08:47 +0900)]
usr.sbin/fstyp: Fix warning on Linux distros

hammer2.c:134: warning: pointer targets in passing argument 1 of 'strcmp' differ in signedness
/usr/include/string.h:143: note: expected 'const char *' but argument is of type 'unsigned char *'

4 years agonrelease: Support to use binary packages
Aaron LI [Sun, 3 Mar 2019 13:19:11 +0000 (21:19 +0800)]
nrelease: Support to use binary packages

Add the new optional target "binpkgs" to allow to use binary packages,
i.e., installing them with pkg(8), instead of building them from
dports(7).  This can be handy for end users who want to quickly build
a custom image with custom packages.

As pointed out by Sascha Wildner, one port may have multiple binary
packages (e.g., Python flavors) or have a different name that may not be
found by pkg(8).  Therefore, allow to specify the exact binary package
name for a port by setting 'PKG_<port>=<pkg-name>'.

This feature is disabled by default, as suggested by Sascha Wildner,
because the release process should be self-contained as much as possible.

Update the help text and man page accordingly.

4 years ago<termios.h>: #define MDMBUF as an alias for CCAR_OFLOW.
Sascha Wildner [Thu, 31 Oct 2019 21:38:41 +0000 (22:38 +0100)]
<termios.h>: #define MDMBUF as an alias for CCAR_OFLOW.

4 years ago<sys/posix4.h>: Remove single use macros.
zrj [Tue, 22 Oct 2019 14:44:26 +0000 (17:44 +0300)]
<sys/posix4.h>: Remove single use macros.

 Use kmalloc()/kfree() directly.

4 years agokernel/vfs: Consistently check if MALLOC_DECLARE was defined.
zrj [Sun, 20 Oct 2019 19:12:48 +0000 (22:12 +0300)]
kernel/vfs: Consistently check if MALLOC_DECLARE was defined.

 Keep these checks even in _KERNEL context and even if <sys/malloc.h>
 is included before.  Helps a lot for userland testing.

4 years agokernel: Remove explicit dependencies on <sys/malloc.h> in headers.
zrj [Sun, 20 Oct 2019 18:15:20 +0000 (21:15 +0300)]
kernel: Remove explicit dependencies on <sys/malloc.h> in headers.

 All except <net/if_var.h> for now, it needs decoupling in drm first.
 * Include <sys/malloc.h> in foo.c if they have kmalloc()/kfree() calls.
 * Consistently check if MALLOC_DECLARE was declared before.
 * <sys/mountctl.h>: include <sys/thread.h> for _KERNEL_STRUCTURES too
   since the "struct journal" embeds "struct thread".
 * <sys/tty.h>: Only two kernel sources makes use of M_TTYS.
 * <sys/socketvar2.h>: Make it kernel only header.

4 years agokernel: Minor whitespace cleanup in few sources (part 2).
zrj [Sun, 20 Oct 2019 18:13:22 +0000 (21:13 +0300)]
kernel: Minor whitespace cleanup in few sources (part 2).

 Separated from next.

4 years ago<sys/sysref.h>: Switch to lighter <sys/_malloc.h> header.
zrj [Sun, 20 Oct 2019 18:05:43 +0000 (21:05 +0300)]
<sys/sysref.h>: Switch to lighter <sys/_malloc.h> header.

 * Make <sys/sysref2.h> a kernel only header.
 * Remove sys/types.h includes that follow <sys/param.h> in devfs(5).
 * Add sys/malloc.h includes where it is actually used in sources.

 While there, minor whitespace cleanup.

4 years ago<sys/objcache.h>: Switch to lighter <sys/_malloc.h> header.
zrj [Sun, 20 Oct 2019 17:45:00 +0000 (20:45 +0300)]
<sys/objcache.h>: Switch to lighter <sys/_malloc.h> header.

 Exposing "struct malloc_type" internals is useful even under kernel
 structures namespace. In vmstat(8) this will allow to drop dependency
 on the <sys/malloc.h> header.

4 years agokernel: Remove not needed header includes in AIO stub.
zrj [Fri, 18 Oct 2019 14:43:47 +0000 (17:43 +0300)]
kernel: Remove not needed header includes in AIO stub.

 AIO not available since 91bcbcd6bef430dfa09526e0af9e24fa8319ae50.

4 years ago<sys/slaballoc.h>: Switch to lighter <sys/_malloc.h> header.
zrj [Fri, 18 Oct 2019 14:40:32 +0000 (17:40 +0300)]
<sys/slaballoc.h>: Switch to lighter <sys/_malloc.h> header.

 The <sys/globaldata.h> embeds SLGlobalData that in turn embeds the
 "struct malloc_type".  Adjust several kernel sources for missing
 includes where memory allocation is performed.  Try to use alphabetical
 include order.

 Now (in most cases) <sys/malloc.h> is included after <sys/objcache.h>.
 Once it gets cleaned up, the <sys/malloc.h> inclusion could be moved
 out of <sys/idr.h> to drm Linux compat layer linux/slab.h without side
 effects.

4 years agokernel: Minor whitespace cleanup in few sources.
zrj [Fri, 18 Oct 2019 14:36:39 +0000 (17:36 +0300)]
kernel: Minor whitespace cleanup in few sources.

4 years ago<sys/malloc.h>: Separate basic typedefs to _malloc.h hearder.
zrj [Fri, 18 Oct 2019 13:43:12 +0000 (16:43 +0300)]
<sys/malloc.h>: Separate basic typedefs to _malloc.h hearder.

 This will be used to reduce <sys/globaldata.h> pollution through the
 <sys/slaballoc.h> and will allow not to include <sys/malloc.h> for
 almost every kernel source even if no memory allocations are done.

 While there move MALLOC_DECLARE() macro too, it would help with malloc
 type visibility from headers that define it and will allow finally to
 sort most of the header includes alphabetically without side effects.

4 years ago<termios.h>: Add TABDLY, TAB0 and TAB3 to satisfy POSIX a bit better.
Sascha Wildner [Thu, 31 Oct 2019 21:01:09 +0000 (22:01 +0100)]
<termios.h>: Add TABDLY, TAB0 and TAB3 to satisfy POSIX a bit better.

* TAB3 is what we already have as OXTABS. Make the latter an alias of
  the former in <sys/_termios.h>.

* Add 'tab0' and 'tab3' operands to stty(1) too.

Most other output flags from the POSIX spec deal with actual time delays
'to allow for mechanical or other movement when certain characters are
sent to the terminal'. Blast from the past.

Taken-from: FreeBSD (with some adjustments)

4 years ago<sys/mpipe.h>: Mark as kernel only header.
zrj [Fri, 18 Oct 2019 13:24:43 +0000 (16:24 +0300)]
<sys/mpipe.h>: Mark as kernel only header.

 Not used in any of the kernel headers and should not be included by the
 userland and especially DPorts.  Adjust kern_mpipe.c too.

 While there, minor whitespace cleanup.

4 years ago<sys/event.h>: Make M_KQUEUE static.
zrj [Fri, 18 Oct 2019 12:54:18 +0000 (15:54 +0300)]
<sys/event.h>: Make M_KQUEUE static.

 Used in a single kernel source only.

 While there, minor whitespace cleanup.

4 years ago<sys/dmsg.h>: Reduce userspace pollution a bit.
zrj [Fri, 18 Oct 2019 12:39:40 +0000 (15:39 +0300)]
<sys/dmsg.h>: Reduce userspace pollution a bit.

 Kernel only prototypes where exposed after buildworld fixup in
  840d1679a5091e5e53566251299413a8e90f4cb9
 The 'struct kdmsg_iocom' is embedded in 'struct disk' (sys/disk.h).
 Also forward declare few structs to reduce dependencies.

 While there, remove kdmsg_icrc32*() prototypes that where added in:
  3a5aa68f9b693d86f3b5d5ac9191035f09d18b3e

4 years ago<pthread.h>: Fix typo: __restict -> __restrict.
Sascha Wildner [Thu, 31 Oct 2019 20:24:42 +0000 (21:24 +0100)]
<pthread.h>: Fix typo: __restict -> __restrict.

Reported-by: zrj
4 years agosbin/fsck_hammer2: Remove redundant hammer2_blockref_t in delta stats
Tomohiro Kusumi [Thu, 31 Oct 2019 15:14:08 +0000 (00:14 +0900)]
sbin/fsck_hammer2: Remove redundant hammer2_blockref_t in delta stats

4 years ago<sys/_termios.h>: FWIW, add 460800 and 921600 baud rate defines.
Sascha Wildner [Wed, 30 Oct 2019 21:18:59 +0000 (22:18 +0100)]
<sys/_termios.h>: FWIW, add 460800 and 921600 baud rate defines.

4 years agosbin/fsck_hammer2: Add -c to cache subtree blockref stats for speed
Tomohiro Kusumi [Tue, 29 Oct 2019 17:30:31 +0000 (02:30 +0900)]
sbin/fsck_hammer2: Add -c to cache subtree blockref stats for speed

If blockref scan succeeds and subtree blockref count exceeds a -c
value, cache subtree blockref stats and blockref itself.

This greatly improves speed when multiple PFSes share large parts
of blockrefs via snapshots. If blockrefs were somehow corrupted in
a weird way that exact same copies of blockref appear more than once,
this doesn't work, but should generally be useful.

Note that using a too small -c value may eat memory without much
performance improvement. Also note that using a too large -c value
saves memory but blockrefs may not be cached or used.

A suitable -c value depends on blockref tree structure since it's
a threshold for blockref count. A fs with more than a few GB of
consumption, should use a few thousand or more.

4 years agopthreads - Bypass third-party allocators for internal allocations
Matthew Dillon [Tue, 29 Oct 2019 23:09:33 +0000 (16:09 -0700)]
pthreads - Bypass third-party allocators for internal allocations

* Adjust libthread_xu to always use libc's malloc/free (__malloc,
  __free), bypassing third party allocators.

* Fixes interactions between third party alocators and pthreads
  which often cause deadlocks or other chicken-and-egg issues,
  or require serious hacks to work around.

4 years agotest/cocci: Improve a bit.
Sascha Wildner [Tue, 29 Oct 2019 19:46:08 +0000 (20:46 +0100)]
test/cocci: Improve a bit.

* Remove NELEM.cocci and put its contents into useful_macros.cocci, along
  with more macros (so far only from <sys/param.h).

* Mention in comma.cocci that the devel/ocaml-findlib port is needed for
  that patch.

4 years agoUse NULL for pointers in tools/usbtest too (forgotten in last commit).
Sascha Wildner [Tue, 29 Oct 2019 19:28:34 +0000 (20:28 +0100)]
Use NULL for pointers in tools/usbtest too (forgotten in last commit).

4 years agousb: Use NULL for pointers.
Sascha Wildner [Tue, 29 Oct 2019 19:26:18 +0000 (20:26 +0100)]
usb: Use NULL for pointers.

4 years agoboot/efi: Use NULL for a pointer.
Sascha Wildner [Tue, 29 Oct 2019 19:13:49 +0000 (20:13 +0100)]
boot/efi: Use NULL for a pointer.

4 years agodsynth - Allow empty env variable assignment
Matthew Dillon [Tue, 29 Oct 2019 17:27:27 +0000 (10:27 -0700)]
dsynth - Allow empty env variable assignment

* The parser was improperly complaining about empty env variable
  assignments.  Allow the case.

* Allows e.g. STRIP=

Reported-by: yellowrabbit2010
4 years agocpdup(1): Check the return value of asprintf() and exit if fails
Aaron LI [Tue, 29 Oct 2019 14:52:48 +0000 (22:52 +0800)]
cpdup(1): Check the return value of asprintf() and exit if fails

See also: https://github.com/DragonFlyBSD/cpdup/commit/90aee43e060104e974f623924c3dfc0a4359ceb5

Reported by GCC 9.x on Arch Linux.

4 years agocpdup(1): Add '-h' option and sort options in help and code
Aaron LI [Tue, 29 Oct 2019 14:49:41 +0000 (22:49 +0800)]
cpdup(1): Add '-h' option and sort options in help and code

* Add the '-h' option to show the help text
* Sort options in both code and help text
* Remove the redundant '-p' option from the source file
* The '-n' and '-S' options are missing from the help text, so add them.

See also: https://github.com/DragonFlyBSD/cpdup/commit/d87b2a60a95d0382135609bb17a014c8a0b61031

4 years agocpdup(1): Improve the help text a bit
Aaron LI [Tue, 29 Oct 2019 14:43:47 +0000 (22:43 +0800)]
cpdup(1): Improve the help text a bit

* Better format the help text to be clearer.
* The 'dest' argument is mandatory.

See also: https://github.com/DragonFlyBSD/cpdup/commit/22ef5685c8dd2ec770f7f2ee62f54b6e2b5f5f23

4 years agocpdup(1): Minor cleanups
Aaron LI [Tue, 29 Oct 2019 14:39:22 +0000 (22:39 +0800)]
cpdup(1): Minor cleanups

* In 'cpdup.h', remove an inaccurate comment about <strings.h>
  inclusion.
* Change predefined macro '__linux' to '__linux__', meanwhile add an
  empty define of '__dead2' under '__linux__' scope.
* In 'hcproto.c', put static variable 'chflags_warning' inside
  '_ST_FLAGS_PRESENT_' macro scrope.

Referred to the changes I made in the standalone 'cpdup' repo:
https://github.com/DragonFlyBSD/cpdup

4 years agonrelease: Fix 'make restartpkgs'
Aaron LI [Mon, 28 Oct 2019 15:39:29 +0000 (23:39 +0800)]
nrelease: Fix 'make restartpkgs'

'make restartpkgs' is broken because 'make install' would fail if the
port is alreay installed.  Fix this issue by executing 'make deinstall'
first, which would exit cleanly even if the port is not installed yet.

4 years agorelease.7: Sync environment variables with nrelease/Makefile
Aaron LI [Sun, 3 Mar 2019 13:37:28 +0000 (21:37 +0800)]
release.7: Sync environment variables with nrelease/Makefile

Remove obsolete "PKGBIN_MKISOFS" and "IMGUSBDEV".

Add "GITURL_SRC", "GITURL_DPORTS", "LABEL", "IMGSIZE" and "MAKE_JOBS".

Order these variables.

4 years agonrelease: Minor style improvements to the Makefile
Aaron LI [Sun, 3 Mar 2019 13:45:28 +0000 (21:45 +0800)]
nrelease: Minor style improvements to the Makefile

4 years agonrelease: Split "pkgs" target out from "customizeiso" target
Aaron LI [Sun, 3 Mar 2019 13:08:23 +0000 (21:08 +0800)]
nrelease: Split "pkgs" target out from "customizeiso" target

Separate the package installation part from "customizeiso" target out
into the "pkgs" target, in preparation for using binary packages in the
following commit.

Use "rcrestart ldconfig" to replace the ad-hoc "ldconfig" command.

Execute "/etc/periodic/weekly/320.whatis" to build the whatis(1)
database, similar to the locate(8) database with the 310.locate periodic
task.

Some cleanups.

4 years agonrelease: Reorder and clean up the "srcs" target
Aaron LI [Sun, 3 Mar 2019 12:39:35 +0000 (20:39 +0800)]
nrelease: Reorder and clean up the "srcs" target

In the "customizeiso" target, ${ISOROOT}/usr/dports will be removed
after installing packages, this conflicts with its creation in the
"srcs" target.  So reorder the "srcs" target to be after the
"customizeiso" target.

Simplify and clean up the "srcs" target by using the the
"{dports,src}-create-shadow" targets in usr/Makefile.  This greatly
saves space and "git gc --aggressive" has little effects in this case.

4 years agonrelease: Remove obsolete targets and update the help
Aaron LI [Sun, 3 Mar 2019 12:27:17 +0000 (20:27 +0800)]
nrelease: Remove obsolete targets and update the help

The optional targets "installer" and "img" are obsolete and have no
effects, so just remove them.

Update the help text by adding the "nopkgs" optional target.

4 years agonrelease: Simplify by not handling multiple kernel configs
Aaron LI [Sun, 3 Mar 2019 07:32:08 +0000 (15:32 +0800)]
nrelease: Simplify by not handling multiple kernel configs

We don't ship multiple kernels for years, so we can get rid of handling
multiple kernel configs in nrelease/Makefile.  This simplifies the
Makefile and also get rid of the hack of 'SUBDIR += nrelease' in
Makefile.inc1.

Note that users can still override 'KERNCONF' the same as 'buildkernel'.

4 years agonrelease: Replace ${NRLOBJDIR}/nrelease with a temp directory
Aaron LI [Sat, 2 Mar 2019 14:14:06 +0000 (22:14 +0800)]
nrelease: Replace ${NRLOBJDIR}/nrelease with a temp directory

The "${NRLOBJDIR}/nrelease" is only used once in the "buildiso" target,
and this directory doesn't really hold any files.  So use a temporary
directory instead, which also makes the code cleaner.

4 years agousr.sbin/fstyp: Fix comparison against unterminated ondisk string
Tomohiro Kusumi [Mon, 28 Oct 2019 15:24:05 +0000 (00:24 +0900)]
usr.sbin/fstyp: Fix comparison against unterminated ondisk string

4 years agosbin/fsck_hammer2: Fix build procedure comments
Tomohiro Kusumi [Sun, 27 Oct 2019 16:12:17 +0000 (01:12 +0900)]
sbin/fsck_hammer2: Fix build procedure comments

4 years agodrm/linux: Add DEFINE_RATELIMIT_STATE()
François Tigeot [Sun, 27 Oct 2019 14:25:12 +0000 (15:25 +0100)]
drm/linux: Add DEFINE_RATELIMIT_STATE()

Obtained-from: OpenBSD

4 years agodrm: Switch ktime_t to its post-Linux 4.10 definition
François Tigeot [Sun, 27 Oct 2019 14:08:46 +0000 (15:08 +0100)]
drm: Switch ktime_t to its post-Linux 4.10 definition

4 years agokernel/syscons: Add missing lwkt_reltoken() in some error paths.
Sascha Wildner [Sat, 26 Oct 2019 22:10:42 +0000 (00:10 +0200)]
kernel/syscons: Add missing lwkt_reltoken() in some error paths.

4 years agodrm/linux: Make fence contexts 64 bit
François Tigeot [Sat, 26 Oct 2019 20:33:06 +0000 (22:33 +0200)]
drm/linux: Make fence contexts 64 bit

4 years agosail(6): Use NULL for pointers.
Sascha Wildner [Sat, 26 Oct 2019 20:16:40 +0000 (22:16 +0200)]
sail(6): Use NULL for pointers.

4 years agousr.bin/usr.sbin: Use NULL for pointers.
Sascha Wildner [Sat, 26 Oct 2019 20:02:00 +0000 (22:02 +0200)]
usr.bin/usr.sbin: Use NULL for pointers.

4 years agolibc: Use NULL for pointers.
Sascha Wildner [Sat, 26 Oct 2019 19:31:24 +0000 (21:31 +0200)]
libc: Use NULL for pointers.

4 years agopf - Increase default state table limit
Matthew Dillon [Fri, 25 Oct 2019 23:12:06 +0000 (16:12 -0700)]
pf - Increase default state table limit

* Increase the default state table from 10000 entries to 50000
  entries.  Because 10000 is a crazy low value in modern times.

4 years agopf - Fix a few edge cases when the state table gets big
Matthew Dillon [Fri, 25 Oct 2019 22:57:16 +0000 (15:57 -0700)]
pf - Fix a few edge cases when the state table gets big

* Currently when the state table gets big the state timeout can
  be reduced all the way to 0.  This can totally mess up legitimate
  connections.

  Change the algorithm.  First calculate a reduction in the timeout
  from 0% to 100%, then claw-back up to 50% of the reduction based on
  the number of packets impacting the state.  This gives the system
  the chance to reject bad state over good state or otherwise requires
  an attacker to DOS the state table based on packet rate, which is
  much harder to do.

* When sloppy state tracking is specified use a timeout of
  PFTM_TCP_FIRST_PACKET instead of PFTM_TCP_ESTABLISHED for any tcp
  state that has only received SYN or SYN+ACK packets.  That is, do not
  use the full PFTM_TCP_ESTABLISHED timeout until some data actually flows.

  This reduces state bloat from redirect traffic where PF might see SYN
  or SYN+ACK and then never sees a packet again while in SLOPPY mode.

4 years agosys/vfs/msdosfs: Drop redundant ->uio_offset limit check
Tomohiro Kusumi [Fri, 25 Oct 2019 15:44:29 +0000 (00:44 +0900)]
sys/vfs/msdosfs: Drop redundant ->uio_offset limit check

4 years agosys/vfs/msdosfs: Remove DragonFly specific macro de_off2cn()
Tomohiro Kusumi [Fri, 25 Oct 2019 15:44:14 +0000 (00:44 +0900)]
sys/vfs/msdosfs: Remove DragonFly specific macro de_off2cn()

4afd80f1a2 contains several fixes, but from the way de_cluster()
is used, an explicitly casted version of de_cluster() shouldn't
be needed.

Note that maximum cluster# (and file relative cluster# too) in
FAT12/16/32 is much smaller than maximum int32_t value. Note that
maximum file size in FAT12/16/32 is < 4GiB.

4 years agosys/vfs/msdosfs: Remove DragonFly specific macro de_off2bn()
Tomohiro Kusumi [Fri, 25 Oct 2019 15:43:55 +0000 (00:43 +0900)]
sys/vfs/msdosfs: Remove DragonFly specific macro de_off2bn()

which is only used once.
Using ->pm_bnshift is clear enough, and more readable in this case.

4 years agosys/vfs/msdosfs: Remove confusing code on cluster#
Tomohiro Kusumi [Fri, 25 Oct 2019 15:43:41 +0000 (00:43 +0900)]
sys/vfs/msdosfs: Remove confusing code on cluster#

Sync comments with FreeBSD.

4 years agodrm/linux: Align Linux memory allocations to cache lines
François Tigeot [Fri, 25 Oct 2019 17:18:15 +0000 (19:18 +0200)]
drm/linux: Align Linux memory allocations to cache lines

4 years agoFix wrong dates in several manual pages.
Sascha Wildner [Thu, 24 Oct 2019 19:20:09 +0000 (21:20 +0200)]
Fix wrong dates in several manual pages.

4 years agogetifaddrs.3: Fix macro (.PP -> .Pp).
Sascha Wildner [Thu, 24 Oct 2019 19:13:18 +0000 (21:13 +0200)]
getifaddrs.3: Fix macro (.PP -> .Pp).

4 years agodsynth.1: Fix wording (reported by noob237).
Sascha Wildner [Thu, 24 Oct 2019 18:27:52 +0000 (20:27 +0200)]
dsynth.1: Fix wording (reported by noob237).

4 years agosys/vfs/msdosfs: Remove obsolete comment
Tomohiro Kusumi [Thu, 24 Oct 2019 17:35:56 +0000 (02:35 +0900)]
sys/vfs/msdosfs: Remove obsolete comment

from freebsd/freebsd@860493e2052cc33a6abb2a55500f908beeffbe85

4 years agosys/vfs/msdosfs: Fix comment on symlink
Tomohiro Kusumi [Thu, 24 Oct 2019 17:35:35 +0000 (02:35 +0900)]
sys/vfs/msdosfs: Fix comment on symlink

from freebsd/freebsd@a74bc23d1f0b8bc77bc0932b3464b83bdde0e70c

4 years agosys/vfs/msdosfs: Remove VREG/VDIR support from msdosfs_mknod()
Tomohiro Kusumi [Thu, 24 Oct 2019 17:35:11 +0000 (02:35 +0900)]
sys/vfs/msdosfs: Remove VREG/VDIR support from msdosfs_mknod()

from freebsd/freebsd@34e9a6f37025fbfbdfb432241cc89ae3533011b0

4 years agokernel: Move M_LWKTMSG declaration to <sys/msgport2.h>.
zrj [Fri, 18 Oct 2019 10:58:45 +0000 (13:58 +0300)]
kernel: Move M_LWKTMSG declaration to <sys/msgport2.h>.

 Including <sys/malloc.h> has side effects, its introduction in this
 header was done in 6aad077d69b6a2d39405e25c987bb090ff78a724.
 The msgport2.h is a better place for M_LWKTMSG since all users already
 include this header directly or indirectly through <net/netmsg2.h>.

 Also, this moves <sys/malloc.h> inclusion after <sys/globaldata.h> down
 the chain when including <sys/systm.h> (TBA later).

 Fix a single case where malloc.h where not included before <sys/mount.h>
 for M_MOUNT.

4 years agokernel: Fix spurious M_IOV declarations.
zrj [Fri, 18 Oct 2019 09:19:44 +0000 (12:19 +0300)]
kernel: Fix spurious M_IOV declarations.

 Do not include <sys/malloc.h> unconditionally in <sys/uio.h> as it only
 hides issues in other headers and source codes.
 * Include <sys/malloc.h> before <sys/uio.h> in sys_generic.c for M_IOV.

4 years agokernel: Cleanup <sys/uio.h> issues.
zrj [Fri, 18 Oct 2019 08:46:47 +0000 (11:46 +0300)]
kernel: Cleanup <sys/uio.h> issues.

 The iovec_free() inline very complicates this header inclusion.  The
 NULL check is not always seen from <sys/_null.h>.  Luckily only three
 kernel sources needs it: kern_subr.c, sys_generic.c and uipc_syscalls.c.
 Also just a single dev/drm source makes use of 'struct uio'.
 * Include <sys/uio.h> explicitly first in drm_fops.c to avoid kfree()
   macro override in drm compat layer.
 * Use <sys/_uio.h> where only enums and struct uio is needed, but ensure
   that userland will not include it for possible later <sys/user.h> use.
 * Stop using <sys/vnode.h> as shortcut for uiomove*() prototypes.  The
   uiomove*() family functions possibly transfer data across kernel/user
   space boundary.  This header presence explicitly mark sources as such.
 * Prefer to add <sys/uio.h> after <sys/systm.h>, but before <sys/proc.h>
   and definitely before <sys/malloc.h> (except for 3 mentioned sources).
   This will allow to remove <sys/malloc.h> from <sys/uio.h> later on.
 * Adjust <sys/user.h> to use component headers instead of <sys/uio.h>.

 While there, use opportunity for a minimal whitespace cleanup.

 No functional differences observed in compiler intermediates.

4 years ago<sys/nlookup.h>: Style(9) adjustments.
zrj [Fri, 18 Oct 2019 07:05:01 +0000 (10:05 +0300)]
<sys/nlookup.h>: Style(9) adjustments.

 Sort prototypes by name and fix long lines.

4 years agolibdmsg: Forward declare struct iovec for public prototypes.
zrj [Fri, 18 Oct 2019 06:45:09 +0000 (09:45 +0300)]
libdmsg: Forward declare struct iovec for public prototypes.

 This removes the need to include <sys/socket.h> or <sys/uio.h> to use
 the <dmsg.h>.  The dmsg_crypto_encrypt() and dmsg_crypto_decrypt() are
 used locally, maybe worth to internalize.

 While there, remove not needed <sys/uio.h> inclusion from hammer2(8).

4 years agoCleanup <sys/uio.h> includes.
zrj [Fri, 18 Oct 2019 05:53:07 +0000 (08:53 +0300)]
Cleanup <sys/uio.h> includes.

 No longer needed after <sys/ktrace.h> cleanup.

4 years ago<sys/uio.h>: Extract kernel structures to a separate header.
zrj [Thu, 17 Oct 2019 15:02:47 +0000 (18:02 +0300)]
<sys/uio.h>: Extract kernel structures to a separate header.

 The only userspace user of these bits is kdump(1) that already properly
 defines _KERNEL_STRUCTURES before including system headers.
 * Put ui_rw and ui_seg enums under _KERNEL_STRUCTURES.
 * Adjust <sys/ktrace.h> for 'struct ktr_genio' visibility too.

 Handling KTR_GENIO requires special knowledge (hidden members) and
 kdump(1) is also a single userspace case using it. This does not affect
 utilities like ktrace(1) and allows for further cleanups.

4 years agokernel: Move M_IOV malloc definition to correct header.
zrj [Thu, 17 Oct 2019 11:41:17 +0000 (14:41 +0300)]
kernel: Move M_IOV malloc definition to correct header.

 It is possible because <sys/uio.h> already must include the
 <sys/malloc.h> unconditionally for _KERNEL.

 While there, minor trailing whitespaces cleanup.

4 years ago<sys/uio.h>: Cleanup namespace.
zrj [Thu, 17 Oct 2019 11:32:42 +0000 (14:32 +0300)]
<sys/uio.h>: Cleanup namespace.

 Certain care is needed while handling this, lots of namespace issues.
 The <sys/_null.h> is needed for sys/vfs/hammer/hammer_ondisk.c through
 <sys/nlookup.h> that would benefit from separated uio enums.

4 years agoRevert "wpa_supplicant: Avoid cpp warning during buildworld."
zrj [Thu, 17 Oct 2019 11:26:41 +0000 (14:26 +0300)]
Revert "wpa_supplicant: Avoid cpp warning during buildworld."

This reverts commit ddaf9f4ac09fd506d0ed3a635e1048beafae310c.

Will no longer be needed after <sys/uio.h> namespace cleanup.

4 years agolibtcplay: Adjust to use <sys/param.h> header.
zrj [Thu, 24 Oct 2019 07:30:05 +0000 (10:30 +0300)]
libtcplay: Adjust to use <sys/param.h> header.

 After ed183f8c2f9bb14cbccb8377f3cdd29e0971d8a0 this header is mandatory.

4 years agolibc: Fix buildworld.
Sascha Wildner [Thu, 24 Oct 2019 06:26:48 +0000 (08:26 +0200)]
libc: Fix buildworld.

4 years agoRevert "world/kernel: Use the roundup2() macro in various places."
Tomohiro Kusumi [Wed, 23 Oct 2019 20:55:47 +0000 (05:55 +0900)]
Revert "world/kernel: Use the roundup2() macro in various places."

This reverts commit 234a54e74c83964aeb996eabab3139f72c68820f.

4 years agoworld/kernel: Use the {set,clr}bit() and is{set,clr}() macros a bit more.
Sascha Wildner [Wed, 23 Oct 2019 18:10:07 +0000 (20:10 +0200)]
world/kernel: Use the {set,clr}bit() and is{set,clr}() macros a bit more.

Tested-by: zrj
4 years agoworld/kernel: Use the rounddown2() macro in various places.
Sascha Wildner [Wed, 23 Oct 2019 18:09:23 +0000 (20:09 +0200)]
world/kernel: Use the rounddown2() macro in various places.

Tested-by: zrj
4 years agoworld/kernel: Use the rounddown() macro in various places.
Sascha Wildner [Wed, 23 Oct 2019 18:09:05 +0000 (20:09 +0200)]
world/kernel: Use the rounddown() macro in various places.

Tested-by: zrj
4 years agoworld/kernel: Use the roundup2() macro in various places.
Sascha Wildner [Wed, 23 Oct 2019 18:08:40 +0000 (20:08 +0200)]
world/kernel: Use the roundup2() macro in various places.

Tested-by: zrj
4 years agosys/vfs/msdosfs: msdosfs_read()/msdosfs_write() fixes
Tomohiro Kusumi [Wed, 23 Oct 2019 15:50:09 +0000 (00:50 +0900)]
sys/vfs/msdosfs: msdosfs_read()/msdosfs_write() fixes

bits from freebsd/freebsd@7fe18219e6aee76fd67b0019f4271f895994aa01

but keep uio sanity checks removed by this commit in FreeBSD.

4 years agosys/vfs/msdosfs: Fix comments in msdosfs_setattr()
Tomohiro Kusumi [Wed, 23 Oct 2019 15:37:18 +0000 (00:37 +0900)]
sys/vfs/msdosfs: Fix comments in msdosfs_setattr()

from freebsd/freebsd@c2333909d4119b0b11bb182ddf4c177bc903d19e

4 years agosys/vfs/msdosfs: Fix style bugs
Tomohiro Kusumi [Wed, 23 Oct 2019 15:30:18 +0000 (00:30 +0900)]
sys/vfs/msdosfs: Fix style bugs

from freebsd/freebsd@fa70acb379635c7b16c8acb3ca68939e65d77434

4 years agosys/vfs/msdosfs: Don't sync update on msdosfs_setattr()
Tomohiro Kusumi [Wed, 23 Oct 2019 15:12:02 +0000 (00:12 +0900)]
sys/vfs/msdosfs: Don't sync update on msdosfs_setattr()

from freebsd/freebsd@896bab2157a7e590750c85dff9cd3dc28f4c8ff9

Read above for details.

4 years ago<sys/signal.h>: Some more whitespace fixes.
Sascha Wildner [Wed, 23 Oct 2019 10:35:58 +0000 (12:35 +0200)]
<sys/signal.h>: Some more whitespace fixes.

4 years agosbin/fsck_hammer2: Fix invalid free(3) of PFS names
Tomohiro Kusumi [Wed, 23 Oct 2019 00:12:25 +0000 (09:12 +0900)]
sbin/fsck_hammer2: Fix invalid free(3) of PFS names

4 years agosbin/fsck_hammer2: Fix copying unterminated ondisk string
Tomohiro Kusumi [Wed, 23 Oct 2019 00:12:11 +0000 (09:12 +0900)]
sbin/fsck_hammer2: Fix copying unterminated ondisk string

4 years agosbin/fsck_hammer2: Sort PFS names to scan on -p
Tomohiro Kusumi [Tue, 22 Oct 2019 20:44:50 +0000 (05:44 +0900)]
sbin/fsck_hammer2: Sort PFS names to scan on -p

4 years agosys/vfs/msdosfs: uniqdosname() assumes 12 bytes char[]
Tomohiro Kusumi [Tue, 22 Oct 2019 19:56:34 +0000 (04:56 +0900)]
sys/vfs/msdosfs: uniqdosname() assumes 12 bytes char[]

from freebsd/freebsd@522790ec8013b64a66fe7410c116e018b63bb9b3

See uniqdosname() and unix2dosfn().

4 years agosys/vfs/msdosfs: Don't set DE_ACCESS on read if readonly mount
Tomohiro Kusumi [Tue, 22 Oct 2019 18:26:27 +0000 (03:26 +0900)]
sys/vfs/msdosfs: Don't set DE_ACCESS on read if readonly mount

from freebsd/freebsd@1b90da9ab8a3ec94fb70dbd7a4204352c038ddda

4 years agosys/vfs/msdosfs: Avoid loop after bread()
Tomohiro Kusumi [Tue, 22 Oct 2019 15:45:06 +0000 (00:45 +0900)]
sys/vfs/msdosfs: Avoid loop after bread()

from freebsd/freebsd@992424e04cb1bcbf73836635d42aeefd1bde73b9

4 years agosys/vfs/msdosfs: Rewrite msdosfs_readdir()
Tomohiro Kusumi [Mon, 21 Oct 2019 17:21:48 +0000 (02:21 +0900)]
sys/vfs/msdosfs: Rewrite msdosfs_readdir()

Don't make the entire function look different from FreeBSD when
vop_write_dirent() (since fc46f680a7 in 2005) is just a wrapper.
Revive dirent local variable to make it easier to sync with FreeBSD
changes, and sync with FreeBSD.

4 years agosys/vfs/msdosfs: Fix FAT32 dotdot dirent corruption
Tomohiro Kusumi [Mon, 21 Oct 2019 17:21:16 +0000 (02:21 +0900)]
sys/vfs/msdosfs: Fix FAT32 dotdot dirent corruption

from freebsd/freebsd@96b12145fb2d0521fe7cd4e58d4691a3cf2861ea

4 years agosys/kern: Add init_va_filerev()
Tomohiro Kusumi [Mon, 21 Oct 2019 17:20:51 +0000 (02:20 +0900)]
sys/kern: Add init_va_filerev()

from freebsd/freebsd@1912367ebb1a5029d72a6b3b028c32f0af41f0b5

Note that init_va_filerev() implementation is not same as FreeBSD.
The existing FAT code using long in union _qcvt was probably a bug.

4 years agosbin/fsck_hammer2: Minor fix/cleanup
Tomohiro Kusumi [Mon, 21 Oct 2019 17:20:18 +0000 (02:20 +0900)]
sbin/fsck_hammer2: Minor fix/cleanup

4 years ago<math.h>: Reduce namespace pollution.
Sascha Wildner [Tue, 22 Oct 2019 14:19:40 +0000 (16:19 +0200)]
<math.h>: Reduce namespace pollution.

4 years ago<signal.h>: Clean up the POSIX namespace a bit.
Sascha Wildner [Tue, 22 Oct 2019 14:19:04 +0000 (16:19 +0200)]
<signal.h>: Clean up the POSIX namespace a bit.

Put the previous and heavier includes into __BSD_VISIBLE because some
dports expect for example <sys/select.h> to come in along with <signal.h>,
none of which request a POSIX environment, though.

Thanks to zrj for testing it with a dports bulk build.