dragonfly.git
18 months agoroute(4): Fix ifam_addrflags in ifa_msghdr
Roy Marples [Mon, 20 Mar 2023 21:00:19 +0000 (21:00 +0000)]
route(4): Fix ifam_addrflags in ifa_msghdr

So I forgot to include the header to work out if INET6 is enabled
or not AND the header to actually get to the INET6 parts of the ifa.

This change allows the original commit I made 4 years ago to
actually work ..... my bad.

18 months agosbin/{mount,newfs}_hammer2: style(9)
Tomohiro Kusumi [Mon, 20 Mar 2023 07:10:38 +0000 (00:10 -0700)]
sbin/{mount,newfs}_hammer2: style(9)

> normally, include <sys/types.h> OR <sys/param.h>, but not both.

18 months agodsynth - Fix bug, but actually keep the behavior
Matthew Dillon [Sun, 19 Mar 2023 03:36:55 +0000 (20:36 -0700)]
dsynth - Fix bug, but actually keep the behavior

* Fix a bug where dexec was not copying the entry environment.
  But actually, that is the behavior we want (a clean environment
  prior to adding our own dsynth-managed environment) so then
  comment out the code.

Reported-by: mjg
18 months agosbin/newfs_hammer2: Don't allow >64 values for -s option
Tomohiro Kusumi [Fri, 17 Mar 2023 08:12:08 +0000 (01:12 -0700)]
sbin/newfs_hammer2: Don't allow >64 values for -s option

HAMMER2_MAX_VOLUMES == 64 is maximum number of volumes.

18 months agosbin/hammer2: Fix minor strdup(3) leak
Tomohiro Kusumi [Fri, 17 Mar 2023 07:07:07 +0000 (00:07 -0700)]
sbin/hammer2: Fix minor strdup(3) leak

strchr(3) moves p while in the loop,
so p is usually NULL when free(3) is called.

18 months agosbin/newfs_hammer2: Expand -s option to allow >1 values for multi-volumes
Tomohiro Kusumi [Fri, 17 Mar 2023 06:30:37 +0000 (23:30 -0700)]
sbin/newfs_hammer2: Expand -s option to allow >1 values for multi-volumes

If -s option takes a single value, the behavior doesn't change.
The value is considered a limit for the total space.

If -s option takes multiple values using ':' separator, each value
is considered a limit for each multi-volumes volume, rather than each
volume size deducted from remaining size.

If multiple values is specified, number of values must match
number of volumes.

18 months agobacklight(9): Add manpage.
Antonio Huete Jimenez [Mon, 13 Mar 2023 08:20:04 +0000 (09:20 +0100)]
backlight(9): Add manpage.

Noticed-by: @aly
18 months agobacklight(9): Initial port.
Antonio Huete Jimenez [Sat, 11 Mar 2023 18:25:47 +0000 (19:25 +0100)]
backlight(9): Initial port.

 - backlight(9) is a generic panel backlight driver.
 - backlight(8) is the userland program to control
   backlight devices' properties.
 - Required by linuxkpi

Taken from: FreeBSD

18 months agocpucontrol.8: Fix markup error in SYNOPSIS
Aaron LI [Sat, 11 Mar 2023 05:45:02 +0000 (13:45 +0800)]
cpucontrol.8: Fix markup error in SYNOPSIS

Obtained-from: FreeBSD

18 months agolibc: Fix a typo. It's local storage, not locale storage.
Sascha Wildner [Thu, 9 Mar 2023 08:36:30 +0000 (09:36 +0100)]
libc: Fix a typo. It's local storage, not locale storage.

18 months agosbin/newfs_hammer2: Add newfs(8) -s option equivalent option
Tomohiro Kusumi [Mon, 6 Mar 2023 08:48:04 +0000 (00:48 -0800)]
sbin/newfs_hammer2: Add newfs(8) -s option equivalent option

Very useful for testing, file backed volume, etc.
The difference vs newfs(8) is newfs_hammer2(8) takes filesystem
size in bytes, using the same format as -b or -r options.

The volume size is deducted from the value (in argv[i] order,
where argc is number of volumes), and if the value reaches zero
while there are remaining volumes, the program fails.

Since -s option requires 1GiB (level1 size) or larger,
the failure mentioned above happens only for multi-volumes.

18 months agoRevert "sys/vfs/hammer2: Avoid void* pointer arithmetic"
Tomohiro Kusumi [Mon, 6 Mar 2023 08:16:39 +0000 (00:16 -0800)]
Revert "sys/vfs/hammer2: Avoid void* pointer arithmetic"

This reverts commit 3f53c53686fc9e236fb9949c8d2a665ce27832be.

Unlike makefs' buf::b_data in DragonFly
(until 02f727fe249ae3252e4721f806f49ded0544938e),
the kernel buf::b_data in DragonFly has always been of caddr_t,
so explicit cast was never needed.

18 months agolibc: Sort SRCS in stdio/.
Sascha Wildner [Sun, 5 Mar 2023 10:49:43 +0000 (11:49 +0100)]
libc: Sort SRCS in stdio/.

18 months agomk: Improve handling of MLINKS
Aaron LI [Sat, 4 Mar 2023 10:41:12 +0000 (18:41 +0800)]
mk: Improve handling of MLINKS

- Use '.for' multi-variable loop to simplify the handling of MLINKS, and
  thus make the code cleaner and more readable.

- Merge the MLINKS installation of man pages and catman pages, and thus
  remove duplicate code.

- This change also gives one benefit: if MLINKS has odd-number items,
  make will just fail the parsing and refuse to execute.  This can
  prevent messing up the man page hardlinks.

As suggested by swildner, performed a 'maninstall' test and the result
was identical.

Obtained-from: FreeBSD (revisions 284685 and 295229)

18 months agomk: Add some comments arond long .else/.endif
Aaron LI [Sat, 4 Mar 2023 10:40:26 +0000 (18:40 +0800)]
mk: Add some comments arond long .else/.endif

18 months agomk: Replace 'sed' command with ':C' variable modifier
Aaron LI [Sat, 4 Mar 2023 10:38:29 +0000 (18:38 +0800)]
mk: Replace 'sed' command with ':C' variable modifier

Obtained-from: FreeBSD

18 months agolibc: Fix installation of fopencookie.3 man page
Aaron LI [Sat, 4 Mar 2023 10:26:40 +0000 (18:26 +0800)]
libc: Fix installation of fopencookie.3 man page

Meanwhile, fix the MLINKS error of having odd number of items, which was
causing the warning: 'warn: empty MLINK: yp_unbind.3 3'

18 months agolibc/ukp_setproctitle: Properly handle skipping the executable's name.
Sascha Wildner [Sat, 4 Mar 2023 02:02:43 +0000 (03:02 +0100)]
libc/ukp_setproctitle: Properly handle skipping the executable's name.

If fmt begins with a "-" character, the executable's name should be
skipped. Our fast version of setproctitle() - which is used after the
10th call to setproctitle() - was not handling that correctly.

While here, fix the case where NULL is passed to setproctitle(), which
restores the process title to its original value. Just defer back to
setproctitle() in this case. Thanks to aly for catching that.

Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3319>

18 months agonet/pf: Remove a bit legacy 32-bit code
Aaron LI [Fri, 3 Mar 2023 06:27:12 +0000 (14:27 +0800)]
net/pf: Remove a bit legacy 32-bit code

18 months agoFix installer build.
Sascha Wildner [Fri, 3 Mar 2023 07:54:13 +0000 (08:54 +0100)]
Fix installer build.

18 months agodsynth - Add Numa_setsize option (defaults to disabled) (2)
Matthew Dillon [Fri, 3 Mar 2023 05:03:13 +0000 (21:03 -0800)]
dsynth - Add Numa_setsize option (defaults to disabled) (2)

* Add missing numa.c file

18 months agokernel/pvscsi: Port pvscsi(4) over to DragonFly.
Sascha Wildner [Tue, 28 Feb 2023 20:52:50 +0000 (21:52 +0100)]
kernel/pvscsi: Port pvscsi(4) over to DragonFly.

* Currently, MSI-X support is missing.

* If loaded as a module, it has to be in loader.conf. I don't know if
  that is different on FreeBSD.

Reported-by: Georg Bege <georg@bege.email>
Tested-by: Georg Bege <georg@bege.email> (on a VPS from IONOS)
             Pierre-Alain TORET <pierre-alain.toret@protonmail.com>
               (on Linux Workstation Pro 17)
             myself (on Windows Workstation 17 Player)

18 months agoBring in FreeBSD's pvscsi(4), for VMware's paravirtual SCSI controller.
Sascha Wildner [Tue, 28 Feb 2023 21:08:18 +0000 (22:08 +0100)]
Bring in FreeBSD's pvscsi(4), for VMware's paravirtual SCSI controller.

Unchanged source from FreeBSD.

18 months agoinstaller(8): Remove passphrase tmp file after use
Aaron LI [Mon, 27 Feb 2023 09:45:49 +0000 (17:45 +0800)]
installer(8): Remove passphrase tmp file after use

18 months agoinstaller(8): Distinguish setting and getting of encryption passphrase
Aaron LI [Sun, 26 Feb 2023 11:59:54 +0000 (19:59 +0800)]
installer(8): Distinguish setting and getting of encryption passphrase

The installer was using the *same* dialog to set and get the passphrase
for filesystem encryption/decryption, which was confusing and a bit
inconvenience (because the passphrase was required to input twice for
decryption).

The decryption passphrase was get in the following two places:
1. Just after installation and begins to configure the system, the
   passphrase is asked to decrypt and mount the filesystems;
2. Use the LiveCD to "Configure an installed System".

This commit improves the fn_get_passphrase() function to distinguish the
setting and getting of the encryption passphrase.  The dialog of setting
the passphrase remains the same, but the dialog of getting the
passphrase is simplified and doesn't require to confirm the input.

This commit is derived from the patch by tuxillo.

Bug: https://bugs.dragonflybsd.org/issues/3028

18 months agodsynth - Add Numa_setsize option (defaults to disabled)
Matthew Dillon [Mon, 27 Feb 2023 07:06:20 +0000 (23:06 -0800)]
dsynth - Add Numa_setsize option (defaults to disabled)

* Currently only for testing purposes and not recommended for general
  use.  Default is 0 (disabled).

* If enabled, a value of 2 or 4 are the only really viable choices,
  otherwise the cpu mask will be so fragmented that even highly
  parallel bulks are going to wind up with cpu threads left idle.

  The NUMA partitioning is hacked at the moment but will generally
  work with both AMD and Intel.

  This works by round-robining N cpumask domains across available builder
  slots.  Insofar as DragonFlyBSD goes, this will localize per-process /
  per-thread anonymous page allocations and kernel memory resources.

* However, DragonFlyBSD still spreads buffer cache pages (the file
  cache) across all domains, including for tmpfs,  The reason is that
  such pages tend to be very long-lived and fully localizing them can
  exhaust the VM page queues for related cpus and domains, forcing
  contention inside vm_page_alloc() as multiple cpu threads contend
  for fewer VM page queue slots.

18 months agokernel - Reduce spin-lock contention issues in page allocator
Matthew Dillon [Mon, 27 Feb 2023 04:50:18 +0000 (20:50 -0800)]
kernel - Reduce spin-lock contention issues in page allocator

* The primary source for cpu-localized exhaustion of VM page queues
  is bio_page_alloc().  Mostly because the related pages tend to be
  very long-lived.  When this occurs, multiple cpus wind up being
  funneled to alternative page queues and wind up with lock
  contention.

* As a first-order solution, use cpuid + ticks to rotate through
  cpu-localized page queues when allocating BIO pages.

  Note that this is not really NUMA friendly, but the kernel has
  a hard time determining which BIO pages might be useful when
  NUMA-localized and which might not be.  We might need to make
  adjustments in the future to retain some localization.

* Significantly reduces vm_page_alloc() contention on heavily
  loaded systems.

19 months agokernel - Add kmalloc_usable_size()
Matthew Dillon [Sat, 25 Feb 2023 19:02:39 +0000 (11:02 -0800)]
kernel - Add kmalloc_usable_size()

* Add kmalloc_usable_size()

Requested-by: tuxillo
19 months agolibc - Port chacha20 from FreeBSD for arc4random()
Matthew Dillon [Sat, 25 Feb 2023 19:01:39 +0000 (11:01 -0800)]
libc - Port chacha20 from FreeBSD for arc4random()

* Port chacha20 from FreeBSD to replace the arc4random() suite.

Requested-by: Zoltan Keri
19 months agonrelease: Add 'IMGSIZE_MB' to specify file size in units of MB
Aaron LI [Fri, 24 Feb 2023 01:16:29 +0000 (09:16 +0800)]
nrelease: Add 'IMGSIZE_MB' to specify file size in units of MB

The image file size was specified by the 'IMGSIZE' variable, but it's
the number of 512-byte sectors, which isn't intuitive and requires a
manual conversion.  Add the 'IMGSIZE_MB' variable to directly specify
the file size in units of MB, which is more intuitive and friendly.

19 months agonrelease: Remove downloaded packages from ISO/IMG
Aaron LI [Thu, 23 Feb 2023 06:19:21 +0000 (14:19 +0800)]
nrelease: Remove downloaded packages from ISO/IMG

19 months agonrelease: Allow /etc/ssl/cert.pem be missing
Aaron LI [Thu, 23 Feb 2023 06:10:13 +0000 (14:10 +0800)]
nrelease: Allow /etc/ssl/cert.pem be missing

The 'pkg-bootstrap' target in '/usr/Makefile' has been updated to work
without '/etc/ssl/cert.pem', so ignore copy failure of this file.

19 months agonrelease: Improve 'etc.hdd' creation to eliminate inconsistency
Aaron LI [Wed, 8 Feb 2023 14:39:47 +0000 (22:39 +0800)]
nrelease: Improve 'etc.hdd' creation to eliminate inconsistency

Previously, the 'etc.hdd' was created during the 'buildiso' target and
then updated in the 'pkgs' target.  However, in the 'pkgs' target, only
the password files (i.e., master.passwd, passwd, group) were copied but
the password DBs (i.e., pwd.db, spwd.db) were not rebuild.  This caused
an inconsistency in 'etc.hdd'.  When a user tried manual installation
and forgot to run 'pwd_mkdb', the installed system would fail to add new
users and generate errors like:

> pw: user 'myuser' disappeared during update.
> adduser: ERROR: There was an error adding user (myuser).

This commit improves the creation of 'etc.hdd'.  Reorder the 'customiso'
target *after* the 'pkgs' target, so we can simply copy the 'etc' to
'etc.hdd' and be done, without any further changes, and the resulting
password files and DBs are in consistency.  In addition, this avoids
adding the 'installer' user to the 'etc.hdd' and so we get a cleaner
system by default.

See also: https://lists.dragonflybsd.org/pipermail/users/2023-February/428576.html
(Regenerating the password databases on new installs)

19 months agobuildworld - Fix bootstrapping from DFly 4.10
Matthew Dillon [Wed, 22 Feb 2023 17:29:34 +0000 (09:29 -0800)]
buildworld - Fix bootstrapping from DFly 4.10

* xinstall has to manually include pwcache.c from libc when creating the
  bootstrap version from an old world.  The Makefile was a bit messed up
  and included pwcache.c twice, as well as included it outside of the
  bootstrap portion of the build, resulting in a link failure.

* Fix the Makefile so this works.  Tested on an old solidrun micro-pc.

19 months agokernel/linker: Support preloaded modules to use full path as name
Aaron LI [Tue, 21 Feb 2023 05:45:54 +0000 (13:45 +0800)]
kernel/linker: Support preloaded modules to use full path as name

Now that the preloaded modules use full paths as their names, so pass
the pathname to preload_delete_name(), and also update it to correctly
compare the pathname to module's MODINFO_NAME field.

Meanwhile, do minor style cleanups.

19 months agoboot/common: Use full root paths for MODINFO_NAME
Aaron LI [Tue, 21 Feb 2023 05:26:56 +0000 (13:26 +0800)]
boot/common: Use full root paths for MODINFO_NAME

Previously, only the basename of kernel/modules was stored in the
MODINFO_NAME field (i.e., 'f_name' field of 'struct preloaded_file').
So kldstat(2) was unable to obtain the full paths of the kernel and
preloaded modules.

This commit makes the full paths be stored in the MODINFO_NAME field.
After bootstrap, the boot partition is mounted at '/boot', so these
full paths must start with '/boot' (e.g., '/boot/kernel/kernel') for
kernel use.

19 months agokernel: Implement sysctl 'debug.dump_modinfo' to dump boot metadata
Aaron LI [Sun, 19 Feb 2023 09:47:23 +0000 (17:47 +0800)]
kernel: Implement sysctl 'debug.dump_modinfo' to dump boot metadata

The boot metadata (also referred to as modinfo, or preload metadata)
provides information about the size and location of the kernel,
pre-loaded modules, and other metadata (e.g. the EFI framebuffer) to be
consumed during by the kernel during early boot. It is encoded as a
series of type-length-value entries and is usually constructed by
loader(8) and passed to the kernel.

Although much of the module information is available via kldstat(8),
there is no easy way to debug the metadata in its entirety. Add some
routines to parse this data and allow it to be printed to the console
during early boot or output via the sysctl 'debug.dump_modinfo'.

Obtained-from: FreeBSD (revision 366542, commit
22e6a670868487bc17e36270eb34f34074693b6a)

19 months agoboot/common: Fix passing of wrong variable in file_load()
Aaron LI [Sun, 19 Feb 2023 09:38:32 +0000 (17:38 +0800)]
boot/common: Fix passing of wrong variable in file_load()

In file_load(), the l_load() method should be passed the argument 'dest'
instead of the global variable 'loadaddr'.  The bug didn't cause real
problem because they're the same.  Neverthless, fix it.

Obtained-from: FreeBSD (commit 0a215cf2d80bf9f44d5e01266de38c26df071b7a)

19 months agoboot/common: Remove obsolete and unused 'slow' command
Aaron LI [Mon, 20 Feb 2023 06:49:43 +0000 (14:49 +0800)]
boot/common: Remove obsolete and unused 'slow' command

This command wasn't mentioned in loader(8) man page.

19 months agoboot/common: Staticize several functions
Aaron LI [Wed, 15 Feb 2023 14:44:14 +0000 (22:44 +0800)]
boot/common: Staticize several functions

Meanwhile, minor cleanups.

19 months agokernel/linker: Resolve module's relative path to full path
Aaron LI [Sun, 12 Feb 2023 07:23:32 +0000 (15:23 +0800)]
kernel/linker: Resolve module's relative path to full path

Before this change, the relative path was stored and shown in
'kldstat -v' output when a relative path was used to load it.
That behavior wasn't actually expected since we really want the full
paths in 'kldstat -v' output to avoid any confusion.  So resolve the
relative paths to absolute full paths.

19 months agokernel/linker: Update 'linker_path' to the current default
Aaron LI [Sun, 12 Feb 2023 07:18:08 +0000 (15:18 +0800)]
kernel/linker: Update 'linker_path' to the current default

The loader(8) now sets 'kern.module_path' sysctl to
'/boot/kernel;/boot/modules.local', so update 'linker_path' to the
current default value.

Update kldconfig(8) man page accordingly.

19 months agokernel/linker: Replace index()/rindex() with strchr()/strrchr()
Aaron LI [Sat, 11 Feb 2023 03:25:20 +0000 (11:25 +0800)]
kernel/linker: Replace index()/rindex() with strchr()/strrchr()

Introduce linker_basename() to reduce some duplicate code.

Obtained-from: FreeBSD

19 months agokldstat(8): Report module's full path in verbose mode
Aaron LI [Fri, 10 Feb 2023 15:24:38 +0000 (23:24 +0800)]
kldstat(8): Report module's full path in verbose mode

Obtained-from: FreeBSD (revision 172862, commit
1676805c186f5dea36d331a982480d7d9693b126)

See also: https://lists.dragonflybsd.org/pipermail/users/2023-January/428489.html

19 months agokldstat(2): Support to report module's full path
Aaron LI [Fri, 10 Feb 2023 15:24:00 +0000 (23:24 +0800)]
kldstat(2): Support to report module's full path

Add 'pathname' field to 'kld_file_stat' and 'linker_file' structs,
enable the kldstat(2) syscall to report the full path of modules.
This also allows kldstat(8) to print the full path of loaded modules,
which may be helpful in debugging.

Bump __DragonFly_version due to syscall interface change.

Obtained-from: FreeBSD (revision 172862, commit
1676805c186f5dea36d331a982480d7d9693b126)

See also: https://lists.dragonflybsd.org/pipermail/users/2023-January/428489.html

19 months agowindow(1): Multiple minor cleanups
Aaron LI [Tue, 21 Feb 2023 06:00:31 +0000 (14:00 +0800)]
window(1): Multiple minor cleanups

The updates to window.1 man page are mostly obtained from NetBSD.

19 months agowait(2): Make WIFSIGNALED(x) exclude WIFCONTINUED(x)
Aaron LI [Tue, 21 Feb 2023 10:40:13 +0000 (18:40 +0800)]
wait(2): Make WIFSIGNALED(x) exclude WIFCONTINUED(x)

So now WIFSIGNALED means the remaining state of not exited, not stopped
and not continued.

Bump __DragonFly_version.

Bug: https://bugs.dragonflybsd.org/issues/3329

Credit:
- NetBSD (https://github.com/NetBSD/src/commit/33e727d2)
- FreeBSD (https://github.com/freebsd/freebsd-src/commit/f24deb02)

19 months agohier(7): Add description for '/usr/src/stand'
Aaron LI [Sun, 19 Feb 2023 13:05:24 +0000 (21:05 +0800)]
hier(7): Add description for '/usr/src/stand'

19 months agoREADME: Describe the 'stand' directory
Aaron LI [Sun, 19 Feb 2023 10:53:14 +0000 (18:53 +0800)]
README: Describe the 'stand' directory

It was moved from 'sys/boot' and 'lib/libstand' in commit
479ab7f0492f2a51b48e8537e4f1dc686fc6014b.

Obtained-from: FreeBSD

19 months agovlan - syntax / cleanup
Matthew Dillon [Wed, 15 Feb 2023 18:17:03 +0000 (10:17 -0800)]
vlan - syntax / cleanup

* Simple cleanups, but also make sure vlantrunks is zero'd when
  allocated.

19 months agokernel - fbsd kpi support, add sleepq*() API (untested)
Matthew Dillon [Wed, 15 Feb 2023 17:53:05 +0000 (09:53 -0800)]
kernel - fbsd kpi support, add sleepq*() API (untested)

* Initial sleepq*() API.  We use our tsleep*() API underneath it.  This
  is a horrible API so add a note that it should only be used for
  FreeBSD compat stuff.

  - Add tsleep/wakeup domains to implement the two sleepq*() queues.

  - Track blocking refs per queue in the sleepq API

  - Do not track individual threads (just let tsleep*()/wakeup*() do
    its thing).

  - objcache for wchan, 1K hash table for now, and retain a cache of
    available wchan structures in the hash table (up to 4 per slot).

  - Include the hash-slot spin lock as FreeBSD compat code will use it
    for interlock tests.

  - Relax sleepq_signal() a bit, allowing it to wakeup more than one
    thread (the DragonFly wakeup_*_one*() is a bit non-deterministic).

* For now add discrete fields to the thread structure.  Its a bit of
  bloat but its better than dynamically allocating a side-structure.
  We already use our tsleep*() API and related fields underneath.
  Add a few more needed for tracking the wchan structure, the queue,
  and the timeout.

* Add sbintime_t type (as 64-bit ticks), and a sbticks global
  counter.  Monotonic ticks since boot, 64 bits.

19 months agotop(1): Handle SCORE (dumping) process state similar to other states
Aaron LI [Wed, 15 Feb 2023 10:43:44 +0000 (18:43 +0800)]
top(1): Handle SCORE (dumping) process state similar to other states

Before this change, the SCORE process state would shown as '?P/5' in the
'STATE' column, which could be confusing.

Similar to existing process states (e.g., running, zombie), handle the
SCORE (dumping a core) process state as well.  This state will show in
the process line in the header, and also shown as 'DUMP' in the 'STATE'
column for such processes.

Update the man page accordingly.  In addition, add copyright text to the
man page.

Reported-by: kworr
19 months agokernel/bus_dmamap_load_ccb: Exit early if data direction is CAM_DIR_NONE.
Sascha Wildner [Sun, 12 Feb 2023 04:18:13 +0000 (05:18 +0100)]
kernel/bus_dmamap_load_ccb: Exit early if data direction is CAM_DIR_NONE.

In this case, there is no data either.

This fixes a crash in the upcoming pvscsi(4) driver.

While here, make the code referencing ccb_h a bit shorter.

19 months agotop(1): Fix STATE column to support all possible states
Aaron LI [Thu, 9 Feb 2023 15:42:08 +0000 (23:42 +0800)]
top(1): Fix STATE column to support all possible states

The old code didn't check all the process states (e.g., SIDL, SSTOP) to
format the STATE column.  So the STATE result could be a bit inaccurate.

Improve the STATE formatting code to explicitly check for all possible
states, similar to the count calculations of all process states.

Update the man page to reflect the current display.

19 months agotop(1): Fix empty 'STATE' column for some system processes
Aaron LI [Thu, 9 Feb 2023 15:22:32 +0000 (23:22 +0800)]
top(1): Fix empty 'STATE' column for some system processes

Fix the wrong usage of 'kl_wmesg' field in 'kinfo_proc' struct.  It's a
char array rather than a 'char *' pointer.  So check whether the
'kl_wmesg' is an empty string before using it.  This fixes the empty
'STATE' column for some system processes.

19 months agotop(1): Fix count of process states
Aaron LI [Thu, 9 Feb 2023 10:29:28 +0000 (18:29 +0800)]
top(1): Fix count of process states

Previously, the 'active' (SACTIVE) process state includes the 'running'
(LSRUN) state.  This caused the total process count was less than the
sum of all process states.

A process consists of one or more LWPs.  The process state (kp_stat)
is more of a meta-state for the process, which can be:
- SIDL: starting
- SACTIVE: active
- SSTOP: stopped
- SZOMB: zombie
- SCORE: about to die (performing a core dump)

For an active process (SACTIVE), the LWP state (kp_lwp.kl_stat)
represents the actual state, which can be:
- LSRUN: running
- LSSTOP: stopped
- LSSLEEP: sleeping

Explicitly check for all the above states and count them, and thus
obtain the correct count of each process state.

19 months agolibc/fopencookie: Additional fix which I forgot in a431bfe52a2aad0a18c.
Sascha Wildner [Thu, 9 Feb 2023 15:15:48 +0000 (16:15 +0100)]
libc/fopencookie: Additional fix which I forgot in a431bfe52a2aad0a18c.

Fixes buildworld.

19 months ago<stdio.h>: Fix issues introduced with the fopencookie() changes.
Sascha Wildner [Thu, 9 Feb 2023 14:53:29 +0000 (15:53 +0100)]
<stdio.h>: Fix issues introduced with the fopencookie() changes.

a765cedf26cef470ba7deee42c365f0221690a1a added fopencookie() and
associated types from FreeBSD but it introduced a number of issues:

* Wrong parentheses caused it to try to (re-)typedef the ssize_t type.
  Fixed by removing parentheses and using __ssize_t. This fixes
  graphics/png as pointed out by David Shao. ssize_t isn't available
  in the compilation environment that graphics/png uses.

* Use off_t which is 64 bits in DragonFly. No need for off64_t.

* Put everything under __BSD_VISIBLE because it is not standard.

* While here, bump the manpage's date properly.

Reported-by: David Shao
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3343>

19 months agodate - Upgrade calculations, add some gnu date -d support
Matthew Dillon [Wed, 8 Feb 2023 18:15:46 +0000 (10:15 -0800)]
date - Upgrade calculations, add some gnu date -d support

* Use long instead of int for numerous calculations, fixing a number of
  date calculation overflow issues.

* Add -d support (a gnu date option).  Make -d an alias for -v.

  In addition to the formats already supported, we now support
  +/-Ndays seconds, minutes, hours, months, years, and abbreviations),
  next ...,
  last ...,
  several month, day, and year arrangements,
  h:m[:s] specifications,
  and a few other things.

  Not all of these can be combined with prefixes and there is still a lot
  of missing support for gnu date compatibility.  In particular the
  handling of TZ= timezone specifications is mis-applied and support for
  the "Z" suffix is missing.

  Localization is still not properly supported for weekday and month names.

* Appears to fix easy-rsa (part of the openvpn package), though easy-rsa
  still has an unrelated openssl/libressl issue.

19 months agoMove mailwrapper(8) examples from /etc/mail to /usr/share/examples.
Sascha Wildner [Sun, 5 Feb 2023 11:23:10 +0000 (12:23 +0100)]
Move mailwrapper(8) examples from /etc/mail to /usr/share/examples.

19 months agoperiodic.conf.5: Note that purgestat is run, not sendmail -bH.
Sascha Wildner [Sun, 5 Feb 2023 10:53:05 +0000 (11:53 +0100)]
periodic.conf.5: Note that purgestat is run, not sendmail -bH.

19 months agohier.7: Adjust for the removal of etc/mtree/BSD.sendmail.dist.
Sascha Wildner [Sat, 4 Feb 2023 21:31:56 +0000 (22:31 +0100)]
hier.7: Adjust for the removal of etc/mtree/BSD.sendmail.dist.

19 months agoFor manual pages from ports, show the ports category/name only the first
Sascha Wildner [Sat, 4 Feb 2023 20:16:09 +0000 (21:16 +0100)]
For manual pages from ports, show the ports category/name only the first
time the page is mentioned but not every time.

19 months agofopencookie(3): Add a wrapper around funopen(3)
Antonio Huete Jimenez [Sat, 4 Feb 2023 13:54:20 +0000 (14:54 +0100)]
fopencookie(3): Add a wrapper around funopen(3)

 - Minor adjustment to _flags since ours reside on the public
   interface.
 - Untested. A unit test would be a good thing to have :)

Taken from    : FreeBSD 877a840c080f
FreeBSD-Review: https://reviews.freebsd.org/D6282

19 months agousr/Makefile: Simplify dports-download and pkg-bootstrap
Aaron LI [Fri, 3 Feb 2023 06:03:01 +0000 (14:03 +0800)]
usr/Makefile: Simplify dports-download and pkg-bootstrap

Use pipe to concatenate fetch(1) and tar(1) and thus get rid of the
temporary download files.

19 months agousr/Makefile: Fix SSL verification issue in pkg bootstrap
Aaron LI [Fri, 3 Feb 2023 05:37:17 +0000 (13:37 +0800)]
usr/Makefile: Fix SSL verification issue in pkg bootstrap

* Use environment variable 'SSL_NO_VERIFY_PEER=1' to let both fetch(1)
  and pkg-static(8) not verify peer when there is not yet a CA store
  (i.e., /etc/ssl/cert.pem from port 'security/ca_root_nss').
* Only check the existence of '/etc/ssl/cert.pem' as fetch(1) only
  checks that by default.
* The newer pkg bootstrap directly provides 'df-latest.conf', so no need
  to copy it from the sample file.  Fix the code to take it into
  account.

Bug: https://bugs.dragonflybsd.org/issues/3338

19 months agopw(8): Allow to change GID of non-root super users (UID=0)
Aaron LI [Fri, 3 Feb 2023 04:03:51 +0000 (12:03 +0800)]
pw(8): Allow to change GID of non-root super users (UID=0)

pw(8) was silently refusing to change the GID/group of super users (i.e.,
UID=0), and thus couldn't change the group of 'toor' user.

Relax the policy a bit and only preventing from changing the GID/group
of 'root' user, and raise an error in that case.  The 'root' is regarded
as the special super user and already has several special checks in the
code.  So this change actually make the behavior more consistent.

This commit fixes the special case of 'tools/pw-update.sh' adding the
'toor' user.  It first adds the user with group of 'nogroup' and later
change to its real group.

Bug: https://bugs.dragonflybsd.org/issues/3332

19 months agotools/pw-update.sh: Adjust primary group of new users only necessary
Aaron LI [Fri, 3 Feb 2023 06:17:33 +0000 (14:17 +0800)]
tools/pw-update.sh: Adjust primary group of new users only necessary

When the primary group of new user exists, just use it, and thus avoid
unnecessary group adjustments for new users.

19 months agotools/pw-update.sh: Allow to create user 'toor' of duplicate UID
Aaron LI [Fri, 3 Feb 2023 01:49:23 +0000 (09:49 +0800)]
tools/pw-update.sh: Allow to create user 'toor' of duplicate UID

The 'toor' user has duplicate UID of 0 as 'root', and it also has an
empty shell field.  This caused problem for the 'pw-update.sh' to
handle.  If the user/admin deliberately removed the 'toor' user, then
this script was unable to add it back, which breaks the 'preinstall'
target and thus 'installworld' failed.

Use the '-o' option for 'pw useradd' to allow to create users of
duplicate UIDs.  In addition, quote the shell field to handle the empty
case.

Bug: https://bugs.dragonflybsd.org/issues/3332

19 months agonet - Fix vlan input packet processing w/ if_bridge, if_carp, etc
Matthew Dillon [Thu, 2 Feb 2023 09:43:50 +0000 (01:43 -0800)]
net - Fix vlan input packet processing w/ if_bridge, if_carp, etc

* if_bridge does not understand VLAN-tagged packets, do not try to
  bridge such packets from the primary interface.  If the user wants
  to bridge such packets it can be done via the virtual vlan interface
  and the vlan tag can be regenerated (or not) with appropriate bridge
  groupings.

  This was causing unicast vlan packets to be discarded in the bridge code.

* Unicast VLAN-tagged packets were not being properly bpf tapped on the
  virtual vlan interface.

* Carp should operate on vlan interfaces, not the original interface, when
  presented with a VLAN-tagged packet.

* Fix all of this by having ether_input_oncpu() bypass more or less directly
  to ether_demux_oncpu() when a M_VLANTAG packet is encountered.  What will
  happen is that if_vlan will issue ether_reinput_oncpu() from the
  appropriate virtual vlan interface, which ultimately re-enters
  ether_input_oncpu() without the tag.

  This is more along the lines of how we want vlans to be treated.  They
  really are supposed to be virtual LANs.

19 months agodsynth - Add section on per-port options
Matthew Dillon [Wed, 1 Feb 2023 18:58:46 +0000 (10:58 -0800)]
dsynth - Add section on per-port options

* Explain how per-port options work in the dsynth manual page.

19 months agousr.sbin/makefs: Fix HAMMER2 section in makefs(8)
Tomohiro Kusumi [Wed, 1 Feb 2023 08:21:32 +0000 (00:21 -0800)]
usr.sbin/makefs: Fix HAMMER2 section in makefs(8)

Copied from cd9660 section, but none of these are optional.

19 months agousr.sbin/makefs: Print too long path in errx()
Tomohiro Kusumi [Wed, 1 Feb 2023 08:16:20 +0000 (00:16 -0800)]
usr.sbin/makefs: Print too long path in errx()

19 months agousr.sbin/makefs: Set HAMMER2 inode mode using source inode
Tomohiro Kusumi [Mon, 30 Jan 2023 08:32:28 +0000 (00:32 -0800)]
usr.sbin/makefs: Set HAMMER2 inode mode using source inode

which is also what other makefs fs do.

19 months agosbin/*hammer2: Remove redundant "CFLAGS+=-DXXH_NAMESPACE=h2_"
Tomohiro Kusumi [Sun, 29 Jan 2023 08:05:15 +0000 (00:05 -0800)]
sbin/*hammer2: Remove redundant "CFLAGS+=-DXXH_NAMESPACE=h2_"

XXH_NAMESPACE as h2_ has been defined in sys/vfs/hammer2/xxhash/xxhash.h
since 30ce27d45c7ee6e8a8cb7da80171265c31a230c3.

19 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Sat, 28 Jan 2023 08:16:20 +0000 (00:16 -0800)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" 66f2c621b4a3c452381030521ca3bb6dadfba431.. -- sys/vfs/hammer2/
1d5238a4ed sys/vfs/hammer2: Fix -Wpointer-sign warnings on hammer2_dirhash()
1b796c7004 sys/vfs/hammer2: Fix -Wpointer-sign warnings

19 months agosys/vfs/hammer2: Fix -Wpointer-sign warnings on hammer2_dirhash()
Tomohiro Kusumi [Fri, 27 Jan 2023 08:34:13 +0000 (00:34 -0800)]
sys/vfs/hammer2: Fix -Wpointer-sign warnings on hammer2_dirhash()

Warned on Linux user space.

Change hammer2_dirhash() and user space dirhash() to take
const char* instead of const unsigned char* for entry "name".

* hammer2_dirhash() callers always pass char* or const char*,
 except for one in sbin/newfs_hammer2/mkfs_hammer2.c where filename[]
 in ondisk inode (unterminated unsigned char array) is used.

* hammer2_dirhash() only compares name with ascii characters,
 and passes substring to hammer2_icrc32() which takes const void*,
 so it doesn't need to be unsigned.

* Also change hammer2_inode_create_pfs() (another function whose
 callers only pass char* or const char* for PFS "name") to take
 const char* instead of const uint8_t* so that hammer2_dirhash()
 doesn't get warned after changes above.

20 months agosys/vfs/hammer2: Fix -Wpointer-sign warnings
Tomohiro Kusumi [Thu, 26 Jan 2023 08:08:08 +0000 (00:08 -0800)]
sys/vfs/hammer2: Fix -Wpointer-sign warnings

Warned on Linux user space.

The name pointer points to namecache name which is of char*.
vnops passes name pointer to hammer2_dirent_create() which takes char*.

warning: pointer targets in passing argument 2 of 'hammer2_dirent_create' differ in signedness [-Wpointer-sign]

20 months agousr.sbin/makefs: Fix -Wformat warnings
Tomohiro Kusumi [Wed, 25 Jan 2023 09:39:56 +0000 (01:39 -0800)]
usr.sbin/makefs: Fix -Wformat warnings

Warned on Linux user space.
makefs(8) HAMMER2 specific part of what was fixed in 4ed61d288d.

warning: format '%jx' expects argument of type 'uintmax_t', but ... [-Wformat=]

20 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Wed, 25 Jan 2023 09:30:21 +0000 (01:30 -0800)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" 347169d4ac18a2d8b3a5e7ac93ccd9823cdac4c9.. -- sys/vfs/hammer2/
4ed61d288d sys/vfs/hammer2: Fix -Wformat warnings
f6ce9317ec sys/vfs/hammer2: Fix -Wint-in-bool-context warning
523dfb54e3 sys/vfs/hammer2: Remove -Wunused-but-set-variable local variables

20 months agousr.sbin/makefs: Remove -Wunused-but-set-variable local variable
Tomohiro Kusumi [Wed, 25 Jan 2023 08:32:59 +0000 (00:32 -0800)]
usr.sbin/makefs: Remove -Wunused-but-set-variable local variable

Warned on Linux user space.

20 months agosys/vfs/hammer2: Fix -Wformat warnings
Tomohiro Kusumi [Wed, 25 Jan 2023 08:22:09 +0000 (00:22 -0800)]
sys/vfs/hammer2: Fix -Wformat warnings

Warned on Linux user space.

warning: format '%jx' expects argument of type 'uintmax_t', but ... [-Wformat=]

20 months agosys/vfs/hammer2: Fix -Wint-in-bool-context warning
Tomohiro Kusumi [Wed, 25 Jan 2023 08:16:40 +0000 (00:16 -0800)]
sys/vfs/hammer2: Fix -Wint-in-bool-context warning

Warned on Linux user space.

warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]

20 months agosys/vfs/hammer2: Remove -Wunused-but-set-variable local variables
Tomohiro Kusumi [Wed, 25 Jan 2023 08:12:13 +0000 (00:12 -0800)]
sys/vfs/hammer2: Remove -Wunused-but-set-variable local variables

Warned on Linux user space.

20 months agousr.sbin/makefs: Use `char *` not `void *` for buf b_data
Tomohiro Kusumi [Tue, 24 Jan 2023 06:42:02 +0000 (22:42 -0800)]
usr.sbin/makefs: Use `char *` not `void *` for buf b_data

, drop casts in msdos

Only struct m_buf change applies in this commit.
"drop casts in msdos" part had already been applied.

taken-from FreeBSD ef63362055dcf60ea2eb532991584c67aab911e2

20 months agousr.sbin/makefs: Rename struct buf -> m_buf
Tomohiro Kusumi [Tue, 24 Jan 2023 04:21:09 +0000 (20:21 -0800)]
usr.sbin/makefs: Rename struct buf -> m_buf

to reduce unnecessary diff vs FreeBSD makefs.

20 months agousr.sbin/makefs: Rename struct vnode -> m_vnode
Tomohiro Kusumi [Tue, 24 Jan 2023 04:12:11 +0000 (20:12 -0800)]
usr.sbin/makefs: Rename struct vnode -> m_vnode

to reduce unnecessary diff vs FreeBSD makefs.

20 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Fri, 20 Jan 2023 07:19:36 +0000 (23:19 -0800)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" 00e4ae5c88a85b6def00615f726e7a037ba13934.. -- sys/vfs/hammer2/
3f53c53686 sys/vfs/hammer2: Avoid void* pointer arithmetic

20 months agoAdd details about forward(5) support by MTA and dma(8) lack of support.
Pierre-Alain TORET [Fri, 13 Jan 2023 16:30:38 +0000 (17:30 +0100)]
Add details about forward(5) support by MTA and dma(8) lack of support.

20 months agoworld - Add /etc/rc.local.d to rcorder startup and shutdown ops
Matthew Dillon [Thu, 12 Jan 2023 05:42:08 +0000 (21:42 -0800)]
world - Add /etc/rc.local.d to rcorder startup and shutdown ops

* System now rcorders across both /etc/rc.d and /etc/rc.local.d
  during startup and shutdown.

* Allows the sysadmin to put control scripts in /etc/rc.local.d
  formatted similarly to how they are in /etc/rc.d

Submitted-by: Stephen Welker <stephen.welker@nemostar.com.au>
20 months agosys/vfs/hammer2: Avoid void* pointer arithmetic
Tomohiro Kusumi [Mon, 9 Jan 2023 08:12:47 +0000 (00:12 -0800)]
sys/vfs/hammer2: Avoid void* pointer arithmetic

Warned on NetBSD.
error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]

This commit only fixes HAMMER2 code.
There are obviously bunch of others in DragonFly tree.

20 months agokernel - Fix early console probe when serial port does not exist
Matthew Dillon [Sun, 8 Jan 2023 02:02:05 +0000 (18:02 -0800)]
kernel - Fix early console probe when serial port does not exist

* Newer machines may ship without any legacy serial ports at all,
  but our default sio0.flags (in the kernel config) are set to 0x10
  to enable console operation if syscons isn't available.

  If the serial port does not actually exist, this will panic or
  livelock the kernel in early boot.

* Fix in two ways.  First, force sioN.disabled to TRUE if the sio
  device probe fails.  If the serial console probe is still reached,
  the serial console probe will also ensure that he serial port is
  able to drain before assigning it.

* Fixes Ryzen 7000 series headless booting.  You can also workaround
  the issue by setting sio0.flags=0 in /boot/loader.conf if you do
  not have a fixed kernel.

20 months agobsd-family-tree: Sync with FreeBSD
Pierre-Alain TORET [Sat, 7 Jan 2023 20:52:48 +0000 (21:52 +0100)]
bsd-family-tree: Sync with FreeBSD

20 months agopkill.1: Add FreeBSD's IMPLEMENTATION NOTES section.
Sascha Wildner [Sat, 7 Jan 2023 18:55:40 +0000 (19:55 +0100)]
pkill.1: Add FreeBSD's IMPLEMENTATION NOTES section.

Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3160>
Reminded-by: daftaupe
20 months agoamd - Add family 19h temperature sensor support, fix 17h support
Matthew Dillon [Sat, 7 Jan 2023 18:42:38 +0000 (10:42 -0800)]
amd - Add family 19h temperature sensor support, fix 17h support

* Add family 19h temperature sensor support.  Note that the
  CCD address offset for models 0x60-0x6f and 0x70-0x7f is
  0x308, not 0x154.

* Fix temperature sensor address base for CCD temps for
  some 17h models.  0x10-0x1f, 0x40-4f, and 0x10-1f models
  use an offset of 0x300, not 0x154.

* Address offset corrections obtained from linux

20 months agobuild - Fix make concurrency for csh
Matthew Dillon [Fri, 6 Jan 2023 07:59:59 +0000 (23:59 -0800)]
build - Fix make concurrency for csh

* Fix a make concurrency issue by making all objects depend on
  the generated headers.

20 months agobuild - Fix make concurrency for libpcap
Matthew Dillon [Fri, 6 Jan 2023 07:59:20 +0000 (23:59 -0800)]
build - Fix make concurrency for libpcap

* Fix a make concurrency issue

20 months agovtnet - Fix panic when larger MTUs are specified
Matthew Dillon [Thu, 5 Jan 2023 21:54:12 +0000 (13:54 -0800)]
vtnet - Fix panic when larger MTUs are specified

* Fix a panic when using vtnet with larger MTUs.

Reported-by: daftaupe
20 months agoBump copyrights. Happy new year!!
Sascha Wildner [Sat, 31 Dec 2022 18:23:00 +0000 (19:23 +0100)]
Bump copyrights. Happy new year!!

21 months agoinstaller: Remove the long-time broken package handling code.
Antonio Huete Jimenez [Wed, 21 Dec 2022 19:17:49 +0000 (20:17 +0100)]
installer: Remove the long-time broken package handling code.