On Tue, Jan 07, 2025 at 08:59:26PM +1100, raf <g...@raf.org> wrote:

> On Mon, Jan 06, 2025 at 04:56:05PM -0500, Bernhard Voelker 
> <invalid.nore...@gnu.org> wrote:
> 
> > Update of bug #46791 (group findutils):
> > 
> >                   Status:                Obsolete => None
> >              Assigned to:                     jay => berny
> >              Open/Closed:                  Closed => Open
> > 
> >     _______________________________________________________
> > 
> > Follow-up Comment #5:
> > 
> > I see that adding such predicates is almost trivial, as the implementation
> > has
> > just to evaluate the already known value of 'struct stat' member 'rdev', and
> > we
> > already deal with major/minor numbers in -ls,-fls (although not in -printf).
> > 
> > I also don't see that this would add much risks or bloat, so it may fit 
> > quite
> > well into find(1).
> > As such, I'm hereby re-opening this one for discussion.
> > 
> > As for the user interface, I'd rather avoid messy parsing of the "x:y"
> > syntax,
> > and instead use the gear we already have for other numerical comparisons
> > (-inum, -gid, -uid, -size, -links) which additionally allows the comparison
> > with +N (COMP_GT), -N (COMP_LT) and exactly N (COMP_EQ).
> > 
> > 
> > # Search the device with number '1:3'.
> > $ find /dev -major 1 -minor 3 -exec ls -logd '{}' +
> > crw-rw-rw- 1 1, 3 Jan  5 23:14 /dev/null
> > 
> > # Search all devices with major number <2.
> > $ find /dev -major -2 -exec ls -logd '{}' +
> > crw-rw-rw- 1 1,  7 Jan  5 23:14 /dev/full
> > crw-r--r-- 1 1, 11 Jan  5 23:14 /dev/kmsg
> > crw-r----- 1 1,  1 Jan  5 23:14 /dev/mem
> > crw-rw-rw- 1 1,  3 Jan  5 23:14 /dev/null
> > crw-r----- 1 1,  4 Jan  5 23:14 /dev/port
> > crw-rw-rw- 1 1,  8 Jan  5 23:14 /dev/random
> > crw-rw-rw- 1 1,  9 Jan  5 23:14 /dev/urandom
> > crw-rw-rw- 1 1,  5 Jan  5 23:14 /dev/zero
> > 
> > # Search for all devices with minor number >300.
> > $ find /dev -type c -minor +300 -exec ls -logd '{}' +
> > crw-rw-r-- 1 189, 384 Jan  5 23:14 /dev/bus/usb/004/001
> > crw-rw-r-- 1 189, 385 Jan  5 23:14 /dev/bus/usb/004/002
> > crw-rw-r-- 1 189, 386 Jan  5 23:14 /dev/bus/usb/004/003
> > 
> > 
> > I prototyped that as new predicate names '-major N -minor N',
> > but I'm not strictly opposed to use more descriptive yet longer names
> > like '-devmajor N -devminor N' or even '-rdev_major N -rdev_minor N'
> > to emphasize that this test is limited to char+block devices.
> > 
> > I'm not sure one would rather like to see a combined '-rdev' test, as
> > e.g. one wouldn't really search with '-rdev 259' for '/dev/null', would one?
> > 
> > Missing at this point: doc (man+texi), tests.
> > 
> > FWIW: the suggested '-major N -minor N' even works for '0:0' devices
> > found in '/run/systemd/inaccessible/' on my system.
> > 
> > Opinions, objections, ...?
> > 
> > (file #56745)
> > 
> 
> Just a thought: Might it better to use , rather than : between
> major,minor device numbers, so as to be similar to ls output?
> It's easier to type (no shift key), and maybe prettier.

Oops. I missed something. Keeping them separate is better.


Reply via email to