]> git.ipfire.org Git - thirdparty/man-pages.git/log
thirdparty/man-pages.git
8 months agoman/man2const/{IPPROTO_IP,IP_ADD_SOURCE_MEMBERSHIP}.2const, man/man2type/ip_mreq_sour...
Alejandro Colomar [Fri, 21 Nov 2025 14:13:51 +0000 (15:13 +0100)] 
man/man2const/{IPPROTO_IP,IP_ADD_SOURCE_MEMBERSHIP}.2const, man/man2type/ip_mreq_source.2type: Split struct ip_mreq_source from IP_ADD_SOURCE_MEMBERSHIP(2const)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2const/IP_ADD_SOURCE_MEMBERSHIP.2const: Tweak after split
Alejandro Colomar [Fri, 21 Nov 2025 12:41:35 +0000 (13:41 +0100)] 
man/man2const/IP_ADD_SOURCE_MEMBERSHIP.2const: Tweak after split

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2const/{IPPROTO_IP,IP_ADD_SOURCE_MEMBERSHIP}.2const: Split IP_ADD_SOURCE_MEMBE...
Alejandro Colomar [Fri, 21 Nov 2025 12:35:03 +0000 (13:35 +0100)] 
man/man2const/{IPPROTO_IP,IP_ADD_SOURCE_MEMBERSHIP}.2const: Split IP_ADD_SOURCE_MEMBERSHIP from IPPROTO_IP(2const)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2type/ip_mreq.2type: Add link page
Alejandro Colomar [Fri, 21 Nov 2025 22:10:35 +0000 (23:10 +0100)] 
man/man2type/ip_mreq.2type: Add link page

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2const/{IPPROTO_IP,IP_ADD_MEMBERSHIP}.2const, man/man2type/ip_mreqn.2type...
Alejandro Colomar [Fri, 21 Nov 2025 21:56:41 +0000 (22:56 +0100)] 
man/man2const/{IPPROTO_IP,IP_ADD_MEMBERSHIP}.2const, man/man2type/ip_mreqn.2type: Split struct ip_mreqn from IP_ADD_MEMBERSHIP(2const)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2const/IP_ADD_MEMBERSHIP.2const: Tweak after split
Alejandro Colomar [Fri, 21 Nov 2025 00:50:49 +0000 (01:50 +0100)] 
man/man2const/IP_ADD_MEMBERSHIP.2const: Tweak after split

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2const/{IPPROTO_IP,IP_ADD_MEMBERSHIP}.2const: Split IP_ADD_MEMBERSHIP from...
Alejandro Colomar [Fri, 21 Nov 2025 00:43:18 +0000 (01:43 +0100)] 
man/man2const/{IPPROTO_IP,IP_ADD_MEMBERSHIP}.2const: Split IP_ADD_MEMBERSHIP from IPPROTO_IP(2const)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man5/proc_sys_net.5: Add reference to proc_sys_net_ipv4(5)
Alejandro Colomar [Fri, 21 Nov 2025 23:07:23 +0000 (00:07 +0100)] 
man/man5/proc_sys_net.5: Add reference to proc_sys_net_ipv4(5)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man5/proc_sys_net_ipv4.5: Tweak after split
Alejandro Colomar [Fri, 21 Nov 2025 22:57:34 +0000 (23:57 +0100)] 
man/man5/proc_sys_net_ipv4.5: Tweak after split

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man7/ip.7, man/man2const/IPPROTO_IP.2const: Split IPPROTO_IP from ip(7)
Alejandro Colomar [Sun, 23 Nov 2025 20:18:52 +0000 (21:18 +0100)] 
man/man7/ip.7, man/man2const/IPPROTO_IP.2const: Split IPPROTO_IP from ip(7)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man7/ip.7, man/man5/proc_sys_net_ipv4.5: Split /proc/sys/net/ipv4/ from ip(7)
Alejandro Colomar [Fri, 21 Nov 2025 22:55:00 +0000 (23:55 +0100)] 
man/man7/ip.7, man/man5/proc_sys_net_ipv4.5: Split /proc/sys/net/ipv4/ from ip(7)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man3/: {str,wcs}n{cmp,len}(3): Remove array parameter length expressions
Alejandro Colomar [Mon, 24 Nov 2025 17:23:46 +0000 (18:23 +0100)] 
man/man3/: {str,wcs}n{cmp,len}(3): Remove array parameter length expressions

The arguments to these APIs may be shorter than that, as long as they
are null terminated strings.

Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2/mremap.2: Fix incorrect reference to VM_MIXEDMAP
Lorenzo Stoakes [Fri, 21 Nov 2025 08:16:09 +0000 (08:16 +0000)] 
man/man2/mremap.2: Fix incorrect reference to VM_MIXEDMAP

We actually disallow VM_DONTEXPAND and VM_PFNMAP for MREMAP_DONTUNMAP,
the manpage incorrectly references VM_MIXEDMAP.

Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Message-ID: <20251121081609.52462-1-lorenzo.stoakes@oracle.com>
Cc: <linux-mm@kvack.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Rik van Riel <riel@surriel.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man7/ip.7: srcfix
Alejandro Colomar [Tue, 18 Nov 2025 14:34:39 +0000 (15:34 +0100)] 
man/man7/ip.7: srcfix

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man7/ip.7: Clarify IP_PKTINFO's semantics depending on packet direction
Jakub Głogowski [Fri, 14 Nov 2025 14:29:30 +0000 (15:29 +0100)] 
man/man7/ip.7: Clarify IP_PKTINFO's semantics depending on packet direction

For recvmsg(2), ipi_spec_dst is set by ipv4_pktinfo_prepare() to the
result of fib_compute_sec_dst().  The latter was introduced in
linux.git 35ebf65e851c6d97 ("ipv4: Create and use fib_compute_spec_dst() helper.").

Quoting its commit message:

> The specific destination is the host we direct unicast replies to.
> Usually this is the original packet source address, but if we are
> responding to a multicast or broadcast packet we have to use something
> different.
>
> Specifically we must use the source address we would use if we were to
> send a packet to the unicast source of the original packet.

Experimentation seems to confirm that behavior.

As for the note about ipi_spec_dst being on a different interface:
- For unicast packets (for which ipi_spec_dst is the original
  destination address), I believe this is trivially true because Linux
  uses the weak host model (unless there's some interaction with
  RTCF_LOCAL that I'm missing).
- For multicast/broadcast packets, fib_compute_sec_dst() only passes the
  original interface to the lookup in the context of L3M.  In
  particular, the original implementation (cited above) set iif and oof
  to 0. Also, citing
linux.git e7372197e15856ec ("net/ipv4: Set oif in fib_compute_spec_dst"),
  > If the device is not enslaved, oif is still 0 so no affect.

It doesn't seem like using an address specifically from the interface
the packet was received on was ever the intention.  I've also confirmed
this behavior (sending a multicast packet from another machine, whose IP
I've routed to a dummy interface).

I'm focusing on this because that's a misconception I've had before
digging into the code - the sendmsg behavior explained in the same
paragraph made me think ipi_spec_dst was the (primary?) address of
ipi_ifindex.  I think this is worth clarifying.

I've made it explicit that ipi_addr isn't used by sendmsg because that's
another possible misconception.

The (first) extra comma in sendmsg's ipi_spec_dst's description is meant
to emphasize that it's used as the local source address _and_ for the
routing table lookup, as opposed to just affecting the routing table
lookup.
Stylistically it might be a bit weird but idk how to convey this better.

Apart from the cited commits I was referencing the linux-6.17.7 tarball.

__fib_validate_source (and the comment near it) might also be of
interest to people trying to figure out what "specific destinations"
are, exactly.

Signed-off-by: Jakub Głogowski <not@dzwdz.net>
Message-ID: <fb3980b64d1c827ad59726bb30761d735396e109.1763130571.git.not@dzwdz.net>
Cc: <linux-kernel@vger.kernel.org>
Cc: <linux-api@vger.kernel.org>
Cc: Jan Engelhardt <ej@inai.de>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man3attr/gnu::warning.3attr: Add page
Alejandro Colomar [Tue, 11 Nov 2025 12:44:35 +0000 (13:44 +0100)] 
man/man3attr/gnu::warning.3attr: Add page

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoCONTRIBUTING.d/ai: Add guidelines banning AI for contributing
Alejandro Colomar [Tue, 14 Oct 2025 21:15:28 +0000 (23:15 +0200)] 
CONTRIBUTING.d/ai: Add guidelines banning AI for contributing

This policy is based on the Gentoo policy (see link below).
However, I've modified our text to be more restrictive.

Link: <https://wiki.gentoo.org/wiki/Project:Council/AI_policy>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: Sam James <sam@gentoo.org>
Cc: "G. Branden Robinson" <branden@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2/flock.2: Mention non-atomicity w.r.t close
Alexander Monakov [Thu, 16 Oct 2025 15:22:36 +0000 (18:22 +0300)] 
man/man2/flock.2: Mention non-atomicity w.r.t close

Ideally one should be able to use flock to synchronize with another
process (or thread) closing that file, for instance before attempting
to execve it (as execve of a file open for writing fails with ETXTBSY).

Unfortunately, on Linux it is not reliable, because in the process of
closing a file its locks are dropped before the refcounts of the file
(as well as its underlying filesystem) are decremented, creating a race
window where execve of the just-unlocked file sees it as if still open.

Linux developers have indicated that it is not easy to fix, and the
appropriate course of action for now is to document this limitation.

Link: <https://lore.kernel.org/linux-fsdevel/68c99812-e933-ce93-17c0-3fe3ab01afb8@ispras.ru/>

Signed-off-by: Alexander Monakov <amonakov@ispras.ru>
Message-ID: <181d561860e52955b29fe388ad089bde4f67241a.1760627023.git.amonakov@ispras.ru>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2/copy_file_range.2: glibc no longer provides fallback after 2.30
Wes Gibbs [Sun, 2 Nov 2025 00:03:30 +0000 (20:03 -0400)] 
man/man2/copy_file_range.2: glibc no longer provides fallback after 2.30

Closes: <https://bugzilla.kernel.org/show_bug.cgi?id=220489>
Signed-off-by: Wes Gibbs <wg21908@gmail.com>
Message-ID: <20251102000330.155591-1-wg21908@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man3/readdir.3, man/man3type/stat.3type: Improve documentation about .d_ino and...
Alejandro Colomar [Wed, 28 May 2025 18:59:11 +0000 (20:59 +0200)] 
man/man3/readdir.3, man/man3type/stat.3type: Improve documentation about .d_ino and .st_ino

Suggested-by: Pali Rohár <pali@kernel.org>
Co-authored-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Pali Rohár <pali@kernel.org>
Co-authored-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: "G. Branden Robinson" <branden@debian.org>
Cc: <linux-fsdevel@vger.kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/: Use '.member' notation for referring to struct/union members
Alejandro Colomar [Wed, 28 May 2025 18:44:28 +0000 (20:44 +0200)] 
man/: Use '.member' notation for referring to struct/union members

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agoman/man2/madvise.2, man/man2const/PR_[GS]ET_THP_DISABLE.2const: document addition...
Usama Arif [Wed, 5 Nov 2025 13:48:11 +0000 (13:48 +0000)] 
man/man2/madvise.2, man/man2const/PR_[GS]ET_THP_DISABLE.2const: document addition of PR_THP_DISABLE_EXCEPT_ADVISED

PR_THP_DISABLE_EXCEPT_ADVISED extended PR_SET_THP_DISABLE to only provide
THPs when advised.  IOW, it allows individual processes to opt-out of
THP = "always" into THP = "madvise", without affecting other workloads
on the system.  The series has been merged in [1].  Before [1], the
following 2 calls were allowed with PR_SET_THP_DISABLE:

prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0);  // reset THP setting.
prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0);  // disable THPs completely.

Now in addition to the 2 calls above, you can do:

// disable THPs except madvise.
prctl(PR_SET_THP_DISABLE, 1, PR_THP_DISABLE_EXCEPT_ADVISED, 0, 0);

This patch documents the changes introduced due to the addition of
PR_THP_DISABLE_EXCEPT_ADVISED flag:
-  PR_GET_THP_DISABLE returns a value whose bits indicate how
   THP-disable is configured for the calling thread (with or without
   PR_THP_DISABLE_EXCEPT_ADVISED).
-  PR_SET_THP_DISABLE now uses arg3 to specify whether to disable THP
   completely for the process, or disable except madvise
   (PR_THP_DISABLE_EXCEPT_ADVISED).

Link: [1] <https://github.com/torvalds/linux/commit/9dc21bbd62edeae6f63e6f25e1edb7167452457b>
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
Message-ID: <20251105134811.3170745-1-usamaarif642@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agosrc/bin/grepc: Remove unnecessary 'sort|uniq' call
Alejandro Colomar [Sun, 9 Nov 2025 10:41:14 +0000 (11:41 +0100)] 
src/bin/grepc: Remove unnecessary 'sort|uniq' call

This was necessary when we used one pcre2grep(1) call per regex.
but long ago we switched to a single pcre2grep(1) call for all regexes,
which only prints each file once, and thus we don't need uniq(1).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
8 months agosrc/bin/grepc, man/man1/grepc.1: -r: Remove flag
Alejandro Colomar [Sun, 9 Nov 2025 10:34:41 +0000 (11:34 +0100)] 
src/bin/grepc, man/man1/grepc.1: -r: Remove flag

Colorizing is imperfect, so don't do it.
Let the user colorize it by piping to grep(1), if needed.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoetc/cpplint/cpplint.cfg: Ignore build/include_what_you_use
Alejandro Colomar [Wed, 5 Nov 2025 17:59:58 +0000 (18:59 +0100)] 
etc/cpplint/cpplint.cfg: Ignore build/include_what_you_use

We already run iwyu(1) on a separate target (lint-c-iwyu).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/, man/man1/grepc{,_c}.1: Various improvements to the scripts; mainly grepc(1)
Alejandro Colomar [Thu, 6 Nov 2025 11:21:21 +0000 (12:21 +0100)] 
src/bin/, man/man1/grepc{,_c}.1: Various improvements to the scripts; mainly grepc(1)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: Use non-capturing groups where possible
Alejandro Colomar [Wed, 5 Nov 2025 23:39:39 +0000 (00:39 +0100)] 
src/bin/grepc_c: Use non-capturing groups where possible

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -te, -tue: Reuse grepc_c_t_sue_decl_()
Alejandro Colomar [Wed, 5 Nov 2025 22:54:46 +0000 (23:54 +0100)] 
src/bin/grepc_c: -te, -tue: Reuse grepc_c_t_sue_decl_()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tt: Add support for enums with underlying type
Alejandro Colomar [Wed, 5 Nov 2025 22:52:00 +0000 (23:52 +0100)] 
src/bin/grepc_c: -tt: Add support for enums with underlying type

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tt, -tut: Reuse code
Alejandro Colomar [Wed, 5 Nov 2025 22:48:37 +0000 (23:48 +0100)] 
src/bin/grepc_c: -tt, -tut: Reuse code

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tt: Remove negative lookahead
Alejandro Colomar [Wed, 5 Nov 2025 22:36:07 +0000 (23:36 +0100)] 
src/bin/grepc_c: -tt: Remove negative lookahead

It was useful when we had separate calls to pcre2grep(1) for each
pattern, but now that we call it once, it's fine to have overlapping
regexes.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tut: Merge grepc_c_ut_su() and grepc_c_ut_td_su()
Alejandro Colomar [Wed, 5 Nov 2025 22:24:19 +0000 (23:24 +0100)] 
src/bin/grepc_c: -tut: Merge grepc_c_ut_su() and grepc_c_ut_td_su()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: Split grepc_c_body_() and grepc_c_u_body_()
Alejandro Colomar [Thu, 6 Nov 2025 00:17:17 +0000 (01:17 +0100)] 
src/bin/grepc_c: Split grepc_c_body_() and grepc_c_u_body_()

grepc_c_u_body_() consumes a lot of resources unnecessarily.
This is especially true within grepc_c_t_td_braced(), which was crashing
with relatively small code.  The reason is that grepc_c_t_td_braced()
searches for code where the identifier is last, so it needs to store
a lot of code just in case.  For that, an optimized grepc_c_body_() is
more appropriate.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tt, -tut: Reuse grepc_c_body_()
Alejandro Colomar [Wed, 5 Nov 2025 21:42:29 +0000 (22:42 +0100)] 
src/bin/grepc_c: -tt, -tut: Reuse grepc_c_body_()

In the last case, it removes part of the regex, but I believe that
wasn't necessary.

Also, while at this, make the trailing of the regexes to be consistently
'[^;];', which is simpler, and seems to work just fine.  If we ever see
some false positives or negatives with this regex, we should fix them
all at once, and maybe put them in a helper function.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tt, -tut: Split regexes
Alejandro Colomar [Wed, 5 Nov 2025 21:27:59 +0000 (22:27 +0100)] 
src/bin/grepc_c: -tt, -tut: Split regexes

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -te, -tue: Add support for enums with underlying type
Alejandro Colomar [Wed, 5 Nov 2025 17:29:48 +0000 (18:29 +0100)] 
src/bin/grepc_c: -te, -tue: Add support for enums with underlying type

This adds support for:

enum : int {
X
};

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -te, -tue: Reuse code from function body
Alejandro Colomar [Wed, 5 Nov 2025 17:24:40 +0000 (18:24 +0100)] 
src/bin/grepc_c: -te, -tue: Reuse code from function body

A function body and an enum body are quite similar.
The same regex works for both.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -te, -tue: Reuse code
Alejandro Colomar [Wed, 5 Nov 2025 17:20:24 +0000 (18:20 +0100)] 
src/bin/grepc_c: -te, -tue: Reuse code

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tum: Split regexes for uses within function-like macros and other...
Alejandro Colomar [Wed, 5 Nov 2025 16:39:02 +0000 (17:39 +0100)] 
src/bin/grepc_c: -tum: Split regexes for uses within function-like macros and other macros

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tum: Merge grepc_c_m_repl_() and grepc_c_um_repl_()
Alejandro Colomar [Wed, 5 Nov 2025 16:33:29 +0000 (17:33 +0100)] 
src/bin/grepc_c: -tum: Merge grepc_c_m_repl_() and grepc_c_um_repl_()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tum: Split regex part for the replacement list
Alejandro Colomar [Wed, 5 Nov 2025 16:29:05 +0000 (17:29 +0100)] 
src/bin/grepc_c: -tum: Split regex part for the replacement list

While splitting, improve the regex part in two ways:

-  Use a non-capturing group.  This improves performance.
-  Use negative lookahead instead of '[^\\]$'.  This allows matching
   a macro where the searched identifier is the last thing in the
   replacement list.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tum: Reuse grepc_c_m_decl_()
Alejandro Colomar [Wed, 5 Nov 2025 16:18:07 +0000 (17:18 +0100)] 
src/bin/grepc_c: -tum: Reuse grepc_c_m_decl_()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tm: Split regexes, and reuse code
Alejandro Colomar [Wed, 5 Nov 2025 16:08:38 +0000 (17:08 +0100)] 
src/bin/grepc_c: -tm: Split regexes, and reuse code

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: Organize regex parts together
Alejandro Colomar [Wed, 5 Nov 2025 15:40:44 +0000 (16:40 +0100)] 
src/bin/grepc_c: Organize regex parts together

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: Rename grepc_c_uf_body_() => grepc_c_f_body_()
Alejandro Colomar [Wed, 5 Nov 2025 15:34:25 +0000 (16:34 +0100)] 
src/bin/grepc_c: Rename grepc_c_uf_body_() => grepc_c_f_body_()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: Use grepc_c_uf_body_() to replace grepc_c_f_body_()
Alejandro Colomar [Wed, 5 Nov 2025 15:33:09 +0000 (16:33 +0100)] 
src/bin/grepc_c: Use grepc_c_uf_body_() to replace grepc_c_f_body_()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tuf: Reuse grepc_c_uf_body_()
Alejandro Colomar [Wed, 5 Nov 2025 15:29:03 +0000 (16:29 +0100)] 
src/bin/grepc_c: -tuf: Reuse grepc_c_uf_body_()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tuf: Split regex for the function body
Alejandro Colomar [Wed, 5 Nov 2025 15:27:26 +0000 (16:27 +0100)] 
src/bin/grepc_c: -tuf: Split regex for the function body

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tuf: Fix regex
Alejandro Colomar [Wed, 5 Nov 2025 15:07:30 +0000 (16:07 +0100)] 
src/bin/grepc_c: -tuf: Fix regex

Fixes: 91c6563acf5e (2025-10-29; "grepc, grepc.1: Add -tu to search for uses")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tuf: Reuse grepc_c_fld_decl_()
Alejandro Colomar [Wed, 5 Nov 2025 14:44:02 +0000 (15:44 +0100)] 
src/bin/grepc_c: -tuf: Reuse grepc_c_fld_decl_()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tfld: Split regex
Alejandro Colomar [Wed, 5 Nov 2025 14:40:05 +0000 (15:40 +0100)] 
src/bin/grepc_c: -tfld: Split regex

This will be reused for -tuf.

I copied '[\w\s,;[\]*\?:+-]*\)' from grepc_c_f_params_().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tfd: Split regex for the function body
Alejandro Colomar [Wed, 5 Nov 2025 14:31:52 +0000 (15:31 +0100)] 
src/bin/grepc_c: -tfd: Split regex for the function body

This regex part will be reused by other regexes.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tflp: Simplify implementation
Alejandro Colomar [Wed, 5 Nov 2025 13:58:25 +0000 (14:58 +0100)] 
src/bin/grepc_c: -tflp: Simplify implementation

This reuses the regex used by -tfp.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tf: These can appear in a parameter list: '+', '-', '?', ':'
Alejandro Colomar [Wed, 5 Nov 2025 13:37:20 +0000 (14:37 +0100)] 
src/bin/grepc_c: -tf: These can appear in a parameter list: '+', '-', '?', ':'

This adds support for function declarators such as:

int
main(int argc, char *argv[argc + 1]);

char *
seprintf(char dst[], const char end[];
    char dst[dst ? end - dst : 0], const char end[0],
    const char *restrict fmt, ...);

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: -tf: Use a named capturing group
Alejandro Colomar [Wed, 5 Nov 2025 13:26:14 +0000 (14:26 +0100)] 
src/bin/grepc_c: -tf: Use a named capturing group

This allows $identifier to contain capturing groups.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: Split regex
Alejandro Colomar [Wed, 5 Nov 2025 13:22:36 +0000 (14:22 +0100)] 
src/bin/grepc_c: Split regex

The regex for a function declarator is too complex.  Split it into
helper functions that prints the parts of the regex, so that each one
is easier to understand.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoshare/mk/: $SHELLCHECKFLAGS: Disable SC2028
Alejandro Colomar [Wed, 5 Nov 2025 17:49:35 +0000 (18:49 +0100)] 
share/mk/: $SHELLCHECKFLAGS: Disable SC2028

It's known that echo(1) doesn't expand anything.  No need to warn.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_*: Use echo(1) instead of printf(1) where possible
Alejandro Colomar [Wed, 5 Nov 2025 12:43:49 +0000 (13:43 +0100)] 
src/bin/grepc_*: Use echo(1) instead of printf(1) where possible

echo(1) is fine as long as the first argument doesn't start with a dash.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc_c: srcfix (align code)
Alejandro Colomar [Wed, 5 Nov 2025 12:40:02 +0000 (13:40 +0100)] 
src/bin/grepc_c: srcfix (align code)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: -r, -l: Don't color the output of -l
Alejandro Colomar [Tue, 4 Nov 2025 14:27:30 +0000 (15:27 +0100)] 
src/bin/grepc: -r, -l: Don't color the output of -l

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: -r: Simplify implementation, removing a conditional
Alejandro Colomar [Tue, 4 Nov 2025 14:18:43 +0000 (15:18 +0100)] 
src/bin/grepc: -r: Simplify implementation, removing a conditional

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: -r: Reimplement with grep(1)
Alejandro Colomar [Tue, 4 Nov 2025 14:11:50 +0000 (15:11 +0100)] 
src/bin/grepc: -r: Reimplement with grep(1)

With grep(1), we don't need to hard-code escape sequences.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/sortman: Fix portability issue
Alejandro Colomar [Mon, 3 Nov 2025 10:30:20 +0000 (11:30 +0100)] 
src/bin/sortman: Fix portability issue

POSIX allows blank characters before '!', but not after.

Reported-by: <onf@disroot.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: -x: Simplify implementation
Alejandro Colomar [Sun, 2 Nov 2025 20:29:04 +0000 (21:29 +0100)] 
src/bin/grepc: -x: Simplify implementation

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc{,_c}.1: Split documentation into a manual page for the driver
Alejandro Colomar [Sun, 2 Nov 2025 20:04:24 +0000 (21:04 +0100)] 
man/man1/grepc{,_c}.1: Split documentation into a manual page for the driver

I've left grepc_mk undocumented for the moment, as it's still not
as stable as the C driver.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc{,_c,_mk}: Align code after split
Alejandro Colomar [Sun, 2 Nov 2025 16:11:42 +0000 (17:11 +0100)] 
src/bin/grepc{,_c,_mk}: Align code after split

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc{,_c,_mk}: Split grepc(1) into helper programs
Alejandro Colomar [Sun, 2 Nov 2025 15:50:50 +0000 (16:50 +0100)] 
src/bin/grepc{,_c,_mk}: Split grepc(1) into helper programs

These programs print the PCRE2 patterns used by grepc(1).  This allows
easily implementing different drivers for parsing different languages.

It also allows easily using pcre2grep(1) in cases where grepc(1) might
be limited; for example, searching in non-regular files, or passing
other flags that grepc(1) doesn't pass to pcre2grep(1).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/: Disable pathname expansion
Alejandro Colomar [Sun, 2 Nov 2025 19:11:44 +0000 (20:11 +0100)] 
src/bin/: Disable pathname expansion

We don't use globs within these scripts, so disable them, for safety
reasons.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Add missing quotes
Alejandro Colomar [Sun, 2 Nov 2025 15:44:18 +0000 (16:44 +0100)] 
src/bin/grepc: Add missing quotes

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc.1: SEE ALSO: Fix references
Alejandro Colomar [Fri, 31 Oct 2025 11:48:12 +0000 (12:48 +0100)] 
man/man1/grepc.1: SEE ALSO: Fix references

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc.1: ffix
Alejandro Colomar [Fri, 31 Oct 2025 10:50:28 +0000 (11:50 +0100)] 
man/man1/grepc.1: ffix

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Handle xargs(1) errors properly
Alejandro Colomar [Thu, 30 Oct 2025 23:58:42 +0000 (00:58 +0100)] 
src/bin/grepc: Handle xargs(1) errors properly

'xargs grep' is hard, because grep(1) exits with a status of 1 for no
match, which is not an error, but xargs(1) takes that as an error, which
is confused with other errors.

This trick with sh(1) was suggested by Paul, and nicely solves this
problem.

We also need to change $opts to be a normal variable.

We can't export bash array variables, and passing them to sh(1) -c is
not great; escapes could be messed.  It's more robust to use a normal
variable.

Link: <https://lists.gnu.org/archive/html/bug-grep/2025-10/msg00029.html>
Suggested-by: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Use the same error code as grep(1)
Alejandro Colomar [Wed, 29 Oct 2025 22:38:20 +0000 (23:38 +0100)] 
src/bin/grepc: Use the same error code as grep(1)

Exit with 2 on error.

If nothing matches, it's a success, and it exits with 0 normally.
This is different from grep(1), but I don't know how to write
the script to exit with 1 if nothing matches.

This implementation may also ignore some xargs(1) errors.  A future
commit --with code suggested by Paul Eggert-- will fix this.

Link: <https://software.codidact.com/posts/294883>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Use if/then/fi instead of &&
Alejandro Colomar [Sun, 2 Nov 2025 16:01:18 +0000 (17:01 +0100)] 
src/bin/grepc: Use if/then/fi instead of &&

It will allow using 'set -Eeuo pipefail' and trap(1) ERR.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc.1: EXAMPLES: Fix command
Alejandro Colomar [Thu, 30 Oct 2025 09:50:40 +0000 (10:50 +0100)] 
man/man1/grepc.1: EXAMPLES: Fix command

The output shows the line number, so it must have been called with -n.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Refactor to avoid process substitution
Alejandro Colomar [Thu, 30 Oct 2025 09:41:55 +0000 (10:41 +0100)] 
src/bin/grepc: Refactor to avoid process substitution

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Add defensive check
Alejandro Colomar [Wed, 29 Oct 2025 22:43:37 +0000 (23:43 +0100)] 
src/bin/grepc: Add defensive check

This is safer than silencing shellcheck(1).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Add defensive check
Alejandro Colomar [Wed, 29 Oct 2025 22:40:38 +0000 (23:40 +0100)] 
src/bin/grepc: Add defensive check

In theory, getopts(1) will make sure that no other values arrive here.
However, it's easy to add a check, and that will be safer than silencing
shellcheck(1).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: srcfix (Simplify case/esac)
Alejandro Colomar [Wed, 29 Oct 2025 22:34:55 +0000 (23:34 +0100)] 
src/bin/grepc: srcfix (Simplify case/esac)

We don't need ';;&' since the commit referenced below.

Fixes: 0ba68dd03564 (2024-09-19, 2025-10-29; "bin/grepc, grepc.1: -k: Remove flag")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoAdapt grepc(1) to the Linux man-pages project
Alejandro Colomar [Wed, 29 Oct 2025 21:49:26 +0000 (22:49 +0100)] 
Adapt grepc(1) to the Linux man-pages project

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc.1: Use a smaller example
Alejandro Colomar [Wed, 29 Oct 2025 21:20:43 +0000 (22:20 +0100)] 
man/man1/grepc.1: Use a smaller example

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Use if/else instead of && and ||
Alejandro Colomar [Wed, 29 Oct 2025 21:12:09 +0000 (22:12 +0100)] 
src/bin/grepc: Use if/else instead of && and ||

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Quote variables
Alejandro Colomar [Wed, 29 Oct 2025 21:04:50 +0000 (22:04 +0100)] 
src/bin/grepc: Quote variables

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Ignore shellcheck(1) diagnostics
Alejandro Colomar [Wed, 29 Oct 2025 21:01:59 +0000 (22:01 +0100)] 
src/bin/grepc: Ignore shellcheck(1) diagnostics

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Use test(1) instead of [(1)
Alejandro Colomar [Wed, 29 Oct 2025 20:57:48 +0000 (21:57 +0100)] 
src/bin/grepc: Use test(1) instead of [(1)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc.1, src/bin/grepc: Add copyright notice
Alejandro Colomar [Wed, 29 Oct 2025 20:47:15 +0000 (21:47 +0100)] 
man/man1/grepc.1, src/bin/grepc: Add copyright notice

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Handle errors
Alejandro Colomar [Wed, 29 Oct 2025 20:39:01 +0000 (21:39 +0100)] 
src/bin/grepc: Handle errors

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc.1: Adapt to the Linux man-pages project
Alejandro Colomar [Wed, 29 Oct 2025 20:37:02 +0000 (21:37 +0100)] 
man/man1/grepc.1: Adapt to the Linux man-pages project

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoman/man1/grepc.1: Move manual page to man/man1/
Alejandro Colomar [Wed, 29 Oct 2025 20:31:08 +0000 (21:31 +0100)] 
man/man1/grepc.1: Move manual page to man/man1/

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agosrc/bin/grepc: Move script to src/bin/
Alejandro Colomar [Wed, 29 Oct 2025 20:30:18 +0000 (21:30 +0100)] 
src/bin/grepc: Move script to src/bin/

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agoImport grepc(1) (script and manual page) from separate project
Alejandro Colomar [Wed, 29 Oct 2025 20:48:02 +0000 (21:48 +0100)] 
Import grepc(1) (script and manual page) from separate project

It started as a script in the Linux man-pages project, under scripts/
within scripts/bash_aliases.

Eventually, I turned it into a large script, and moved it into a
separate project, to be able to work on it more freely.

The original scripts were removed from this project in commit
c3752af0549c (2022-11-22; "bash_aliases: Remove grep_syscall(),
grep_syscall_def(), and grep_glibc_prototype()").

Now, grepc(1) has stabilized, and I find it very useful for maintaining
this project (as well as others), so let's merge it back.  This will
allow distros to package it sooner than if it remained as a standalone
project.

I've imported the git history (ignoring files we don't care about) with
the help of git-filter-repo(1).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc: -tuf: Reuse grepc_c_f_decl_() for the function declarator
Alejandro Colomar [Thu, 9 Oct 2025 19:03:23 +0000 (21:03 +0200)] 
bin/grepc: -tuf: Reuse grepc_c_f_decl_() for the function declarator

It's slightly different than the regex we were using, but I can't see a
reason for it.  It was probably due to forgetting to improve this regex.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc: -tf: Factor out regex for function declarators
Alejandro Colomar [Thu, 9 Oct 2025 18:59:15 +0000 (20:59 +0200)] 
bin/grepc: -tf: Factor out regex for function declarators

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc: -tt: Add word boundary around the identifier
Alejandro Colomar [Thu, 9 Oct 2025 10:36:08 +0000 (12:36 +0200)] 
bin/grepc: -tt: Add word boundary around the identifier

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc: Add robustness against non-portable pathnames
Alejandro Colomar [Sat, 3 May 2025 12:37:19 +0000 (14:37 +0200)] 
bin/grepc: Add robustness against non-portable pathnames

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc: Use <() instead of $()
Alejandro Colomar [Sat, 1 Mar 2025 16:52:43 +0000 (17:52 +0100)] 
bin/grepc: Use <() instead of $()

Files are simpler to handle.  It results in less flags, and simpler
command invocations.  And it allows breaking the line more nicely,
without having to break in the middle of a quoted region.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc: -tfp, -tfd: Add support for forward-declarations of parameters
Alejandro Colomar [Wed, 27 Nov 2024 12:50:53 +0000 (13:50 +0100)] 
bin/grepc: -tfp, -tfd: Add support for forward-declarations of parameters

This is currently a (very useful) GNU extension, and soon might become
standard in C2y.

Link: n3394 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3394.pdf>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc, grepc.1: -k: Remove flag
Alejandro Colomar [Thu, 19 Sep 2024 12:12:57 +0000 (14:12 +0200)] 
bin/grepc, grepc.1: -k: Remove flag

Just behave like grep(1) and pcre2grep(1).  If the user wants to see it
more nicely, they can do it themselves.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/grepc: bugfix: Pass options to grep(1) correctly
Alejandro Colomar [Tue, 7 Nov 2023 17:06:55 +0000 (18:06 +0100)] 
bin/grepc: bugfix: Pass options to grep(1) correctly

Fixes: 92dca8e97bfa ("bin/grepc: srcfix (Variables for options hold their '-')")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
9 months agobin/, man/: -m: Add flag, and pass it to pcre2grep(1)
Alejandro Colomar [Fri, 10 May 2024 10:42:01 +0000 (12:42 +0200)] 
bin/, man/: -m: Add flag, and pass it to pcre2grep(1)

Signed-off-by: Alejandro Colomar <alx@kernel.org>