It previously entered an infinite loop. Now it inserts the `to` string
between every character of `from`, including at the beginning and end.
rename -a '' _ 123.txt # renames to _1_2_3_._t_x_t_
Previously, if we did e.g.
rename '' _ ./foo.txt
it would try to rename to ._/foo.txt, because `string_replace` was
passed `s="/foo.txt"` and `from` would match at the front. Now we pass
`s="foo.txt"`.
This doesn't affect the case when `to` contains a slash. In that
situation we'll still place `to` at the very beginning of the path, e.g.
rename '' _/ ./foo.txt # rename to _/./foo.txt
rename '' /_ ./foo.txt # rename to /_./foo.txt
* 'dm_leaf_holders' of https://github.com/wjordan/util-linux:
Improve is_dm_leaf performance Read from `/holders` instead of `/slaves` to determine whether the device is a leaf node, eliminating a scan across all block devices in the system.
==28129== 96 bytes in 3 blocks are possibly lost in loss record 1 of 4
==28129== at 0x4837B65: calloc (vg_replace_malloc.c:752)
==28129== by 0x405C83: xcalloc (xalloc.h:60)
==28129== by 0x405C83: netnsid_cache_add (lsns.c:389)
==28129== by 0x405C83: get_netnsid (lsns.c:486)
==28129== by 0x405C83: read_process (lsns.c:549)
==28129== by 0x403FB4: read_processes (lsns.c:586)
==28129== by 0x403FB4: main (lsns.c:1417)
==28129==
==28129== 119,664 (384 direct, 119,280 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==28129== at 0x4837B65: calloc (vg_replace_malloc.c:752)
==28129== by 0x4055F5: xcalloc (xalloc.h:60)
==28129== by 0x4055F5: read_process (lsns.c:516)
==28129== by 0x403FB4: read_processes (lsns.c:586)
==28129== by 0x403FB4: main (lsns.c:1417)
`struct ipc' is the data structure used behind ENDPOINTS field.
The objects of the data structure and its hash table were not
freed.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Though the code of lsfd was changed in 4b496e50ee,
the expected output of the test case was not updated.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The definition of O_FOLLOW was checked. However, it was
a typo of O_NOFOLLOW.
The definition of O_FASYNC was checked. However, it was
a typo of FASYNC.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Close#1720
The original code tried including asm-generic/fcntl.h before trying
including asm/fcntl.h. This caused a bug in decoding flag of fdinfo
on Linux running on armv7l.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This commit removes --enable-libmount-support-mtab.
The classic /etc/mtab is broken by design. It does not support
namespaces, chroots, etc. The only sane way to keep track of
mounted filesystems is to ask the kernel. It's a bad idea to maintain
a mount table in userspace.
Signed-off-by: Karel Zak <kzak@redhat.com>
Close#1717.
If the file system where the target directory is is mounted with
"noatime" flag, Linux kernel may set O_NOATIME to the fd associated
with the target directory. As a result, mkfds-directory test failed.
With this change, mkfds-directory deletes "noatime" from the output
of lsfd before verifying the output if "noatime" mount flag is set
to the file system where the directory opened by mkfds-directory is.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
In version 2.38, exit-on-eof has been disabled by default. This change
is annoying for users and forces many users to use 'alias more="more
-e"'. It seems better to force POSIX lovers to use POSIXLY_CORRECT
env. variable and stay backwardly compatible by default.
Addresses: https://github.com/util-linux/util-linux/issues/1703
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2088493
Signed-off-by: Karel Zak <kzak@redhat.com>
Do not call 'PKG_CONFIG --exists' and '$PKG_CONFIG --variable' if
there is a much more robust PKG_CHECK_VAR() macro.
It's also not necessary to check for the dirs if all the feature
(systemd or bashcompletiondir) is disabled.
Reported-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'change-default-comparison-method' of https://github.com/DrHyde/util-linux:
change the default comparison method on Mac OS to suppress a warning that's going to fall back to memcmp
Close#1709.
The original code decoded the field using constants defined in
/usr/include/fcntl.h. The constants defined in /usr/include/fcntl.h
was suitable for passing to the kernel as a part of arguments of
system calls like open(2). However, they were not suitable for
decoding the field.
Let's think about decoding 0300000 in
$ cat /proc/157067/fdinfo/3
pos: 0
flags: 0300000
$ lsfd -p 157067 -o+flags -Q -Q 'ASSOC == "3"'
COMMAND PID USER ASSOC MODE TYPE SOURCE MNTID INODE NAME FLAGS
test_mkfds 125128 jet 3 r-- DIR dm-0 96 96 / ???????????????????
The decoded string is printed at ???????????????????.
Quoted from /usr/include/bits/fcntl-linux.h:
#ifndef __O_LARGEFILE
# define __O_LARGEFILE 0100000
#endif
#ifndef __O_DIRECTORY
# define __O_DIRECTORY 0200000
#endif
#ifndef __O_TMPFILE
# define __O_TMPFILE (020000000 | __O_DIRECTORY)
#endif
...
#ifdef __USE_XOPEN2K8
# define O_DIRECTORY __O_DIRECTORY /* Must be a directory. */
...
#endif
...
#ifdef __USE_LARGEFILE64
# define O_LARGEFILE __O_LARGEFILE
#endif
With these constants, 0300000 is decoded as "directory,_tmpfile" or
"largefile,directory,_tmpfile".
Unexpectedly the decoded string has "_tmpfile".
It has "largefile" only when we define __USE_LARGEFILE64 when building
lsfd though it should have "largefile" always.
Quoted from /usr/include/asm-generic/fcntl.h:
#ifndef O_LARGEFILE
#define O_LARGEFILE 00100000
#endif
#ifndef O_DIRECTORY
#define O_DIRECTORY 00200000 /* must be a directory */
#endif
#ifndef __O_TMPFILE
#define __O_TMPFILE 020000000
#endif
The decoded string is "largefile,directory". It doesn't depend on
__USE_LARGEFILE64.
This change adds lsfd-decode-file-flags.c, a new small and isolated
source file, in which lsfd_decode_file_flags(), the function for
decoding the field is defined.
include/c.h includes /usr/include/fcntl.h. Almost all lsfd related
source files includes include/c.h indirectly. On the other hand,
lsfd-decode-file-flags.c includes only /usr/include/asm-generic/fcntl.h
or /usr/include/asm/fcntl.h. So the function can decode the field
expectedly.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This option affects list of visible columns, so it's better to apply
it before any other flags, because "-1" placeholder depends on visible
columns. For example:
echo "A B C D" | column --table --table-maxout --table-right -1 --table-hide 4
needs to hide column #4 (D) and align #3 (C) to the right.
Signed-off-by: Karel Zak <kzak@redhat.com>