--- /dev/null
+---
+# vi:ts=2 sw=2 et:
+#
+# Docs: https://packit.dev/docs/
+
+specfile_path: .packit_rpm/util-linux.spec
+files_to_sync:
+ - .packit.yaml
+ - src: .packit_rpm/util-linux.spec
+ dest: util-linux.spec
+upstream_package_name: util-linux
+downstream_package_name: util-linux
+# `git describe` returns in util-linux's case 'v2.37.2-xxx' which breaks RPM version
+# # detection (that expects 2.37.2-xxx'). Let's tweak the version string accordingly
+upstream_tag_template: "v{version}"
+srpm_build_deps: []
+
+actions:
+ post-upstream-clone:
+ # Use a spec file from Fedora Rawhide
+ - "git clone https://src.fedoraproject.org/rpms/util-linux.git .packit_rpm --depth=1"
+ # Drop the "sources" file so rebase-helper doesn't think we're a dist-git
+ - "rm -fv .packit_rpm/sources"
+ # Drop all patches, since they're already included in the tarball
+ - "sed -ri '/^Patch[0-9]+:/d' .packit_rpm/util-linux.spec"
+ # Install additional dependencies we need for the build/tests
+ - "sed -i '/^### Dependencies/aBuildRequires: autoconf automake bc bison iproute libtool procps-ng socat' .packit_rpm/util-linux.spec"
+ # We need to call autogen, since we use a custom tarball
+ - "sed -i '/^unset LINGUAS/a./autogen.sh' .packit_rpm/util-linux.spec"
+ # Enable tests after build
+ - "sed -i '/^### Macros/a%define _with_check 1' .packit_rpm/util-linux.spec"
+ # Ignore unpackaged files
+ - "sed -i '1 i%define _unpackaged_files_terminate_build 0' .packit_rpm/util-linux.spec"
+ create-archive:
+ # We need to override the default create-archive action, since we need to tweak
+ # the resulting tarball and add a .tarball-version file to it, otherwise
+ # util-linux fails to detect its version during build
+ - "bash -c 'echo $PACKIT_PROJECT_VERSION >.tarball-version'"
+ - "bash -c 'git archive --prefix ${PACKIT_PROJECT_NAME_VERSION}/ --add-file .tarball-version --output .packit_rpm/${PACKIT_PROJECT_NAME_VERSION}.tar.gz HEAD'"
+ - "bash -c 'echo .packit_rpm/${PACKIT_PROJECT_NAME_VERSION}.tar.gz'"
+
+# Available targets can be listed via `copr-cli list-chroots`
+jobs:
+ # Build test
+ - job: copr_build
+ trigger: pull_request
+ targets:
+ - fedora-rawhide-aarch64
+ - fedora-rawhide-i386
+ - fedora-rawhide-ppc64le
+ - fedora-rawhide-s390x
+ - fedora-rawhide-x86_64
libmount: Karel Zak <kzak@redhat.com>
libuuid: Theodore Ts'o <tytso@mit.edu>
lscpu: Cai Qian <qcai@redhat.com>
- lsblk: Milan Broz <mbroz@redhat.com>
+ lsblk: Milan Broz <gmazyland@gmail.com>
Karel Zak <kzak@redhat.com>
lsfd: Masatake YAMATO <yamato@redhat.com>
lsipc: Ondrej Oprala <ooprala@redhat.com>
Miklos Szeredi <mszeredi@suse.cz>
Mikulas Patocka <mpatocka@redhat.com>
Milan Bouchet-Valat <nalimilan@club.fr>
- Milan Broz <mbroz@redhat.com>
+ Milan Broz <gmazyland@gmail.com>
Ming Lei <tom.leiming@gmail.com>
Miquel van Smoorenburg <miquels@maestro.htsa.aha.nl>
Mister Me <gdg@localhost.localdomain>
# List of characters to escape shamelessly stolen from "scp" completion
local escape_chars='[][(){}<>\",:;^&!$=?`|\\'\'' \t\f\n\r\v]'
- findmnt -lno TARGET | awk '{
- if ($0 ~ "^"ENVIRON["HOME"]) {
+ findmnt -lno TARGET | awk '
+
+ function literal_ere(s) {
+ gsub(/[][^$.*?+{}\\()|]/, "\\\\&", s)
+ return s
+ }
+
+ {
+ home_ere = literal_ere(ENVIRON["HOME"])
+ print home_ere
+ if ($0 ~ "^"home_ere) {
homeless = $0
- sub("^"ENVIRON["HOME"], "~", homeless)
+ sub("^"home_ere, "~", homeless)
gsub("'"$escape_chars"'", "\\\\&", homeless)
print homeless " "
}
- if ($0 ~ "^"ENVIRON["PWD"]) {
+ pwd_ere = literal_ere(ENVIRON["PWD"])
+ if ($0 ~ "^"pwd_ere) {
reldir = $0
- sub("^"ENVIRON["PWD"]"/?", "", reldir)
+ sub("^"pwd_ere"/?", "", reldir)
gsub("'"$escape_chars"'", "\\\\&", reldir)
print "./" reldir " "
print reldir " "
'mkswap.c',
) + \
ismounted_c
+if lib_selinux.found()
+ mkswap_sources += selinux_utils_c
+endif
swaplabel_sources = files(
'swaplabel.c',
#define _PATH_SYS_CLASS "/sys/class"
#define _PATH_SYS_SCSI "/sys/bus/scsi"
#define _PATH_SYS_CPU_BYTEORDER "/sys/kernel/cpu_byteorder"
+#define _PATH_SYS_ADDRESS_BITS "/sys/kernel/address_bits"
#define _PATH_SYS_SELINUX "/sys/fs/selinux"
#define _PATH_SYS_APPARMOR "/sys/kernel/security/apparmor"
};
extern enum sysfs_byteorder sysfs_get_byteorder(struct path_cxt *pc);
+extern int sysfs_get_address_bits(struct path_cxt *pc);
#endif /* UTIL_LINUX_SYSFS_H */
include_directories : dir_include,
dependencies : lib_econf,
)
+selinux_utils_c = files('selinux-utils.c')
if LINUX
lib_common_sources += '''
return sz;
}
-static ssize_t procfs_process_get_line_for(struct path_cxt *pc, char *buf, size_t bufsz,
+static ssize_t procfs_process_get_data_for(struct path_cxt *pc, char *buf, size_t bufsz,
const char *fname)
{
int fd = ul_path_open(pc, O_RDONLY|O_CLOEXEC, fname);
ssize_t procfs_process_get_cmdline(struct path_cxt *pc, char *buf, size_t bufsz)
{
- return procfs_process_get_line_for(pc, buf, bufsz, "cmdline");
+ return procfs_process_get_data_for(pc, buf, bufsz, "cmdline");
}
ssize_t procfs_process_get_cmdname(struct path_cxt *pc, char *buf, size_t bufsz)
{
- return procfs_process_get_line_for(pc, buf, bufsz, "comm");
+ return procfs_process_get_data_for(pc, buf, bufsz, "comm");
}
ssize_t procfs_process_get_stat(struct path_cxt *pc, char *buf, size_t bufsz)
{
- return procfs_process_get_line_for(pc, buf, bufsz, "stat");
+ return procfs_process_get_data_for(pc, buf, bufsz, "stat");
}
int procfs_process_get_stat_nth(struct path_cxt *pc, int n, uintmax_t *re)
if (n == 2 || n == 3) /* process name and status (strings) */
return -EINVAL;
- rc = procfs_process_get_line_for(pc, buf, sizeof(buf), "stat");
+ rc = procfs_process_get_data_for(pc, buf, sizeof(buf), "stat");
if (rc < 0)
return rc;
return ul_strtou64(tok, re, 10);
/* skip rest of the process name */
- if (i == 2 && (p = strchr(key, ')')))
+ if (i == 2 && (p = strrchr(key, ')')))
key = p + 2;
}
#ifdef TEST_PROGRAM_PROCFS
-static int test_tasks(int argc, char *argv[])
+static int test_tasks(int argc, char *argv[], const char *prefix)
{
DIR *sub = NULL;
struct path_cxt *pc;
pid = strtol(argv[1], (char **) NULL, 10);
printf("PID=%d, TIDs:", pid);
- pc = ul_new_procfs_path(pid, NULL);
+ pc = ul_new_procfs_path(pid, prefix);
if (!pc)
err(EXIT_FAILURE, "alloc procfs handler failed");
return EXIT_SUCCESS;
}
-static int test_fds(int argc, char *argv[])
+static int test_fds(int argc, char *argv[], const char *prefix)
{
DIR *sub = NULL;
struct path_cxt *pc;
pid = strtol(argv[1], (char **) NULL, 10);
printf("PID=%d, FDs:", pid);
- pc = ul_new_procfs_path(pid, NULL);
+ pc = ul_new_procfs_path(pid, prefix);
if (!pc)
err(EXIT_FAILURE, "alloc procfs handler failed");
return EXIT_SUCCESS;
}
-static int test_one_process(int argc, char *argv[])
+static int test_one_process(int argc, char *argv[], const char *prefix)
{
pid_t pid;
struct path_cxt *pc;
return EXIT_FAILURE;
pid = strtol(argv[1], (char **) NULL, 10);
- pc = ul_new_procfs_path(pid, NULL);
+ pc = ul_new_procfs_path(pid, prefix);
if (!pc)
err(EXIT_FAILURE, "cannot alloc procfs handler");
return is ? EXIT_SUCCESS : EXIT_FAILURE;
}
-static int test_process_stat_nth(int argc, char *argv[])
+static int test_process_stat_nth(int argc, char *argv[], const char *prefix)
{
pid_t pid;
struct path_cxt *pc;
uintmax_t num = 0;
- int n;
+ int n, ret;
if (argc != 3)
return EXIT_FAILURE;
pid = strtol(argv[1], (char **) NULL, 10);
n = strtol(argv[2], (char **) NULL, 10);
- pc = ul_new_procfs_path(pid, NULL);
+ pc = ul_new_procfs_path(pid, prefix);
if (!pc)
err(EXIT_FAILURE, "cannot alloc procfs handler");
- if (procfs_process_get_stat_nth(pc, n, &num) != 0)
- err(EXIT_FAILURE, "read %dth number failed", n);
+ ret = procfs_process_get_stat_nth(pc, n, &num);
+ if (ret)
+ errx(EXIT_FAILURE, "read %dth number failed: %s", n, strerror(-ret));
printf("%d: %dth %ju\n", (int) pid, n, num);
ul_unref_path(pc);
int main(int argc, char *argv[])
{
+ const char *prefix = NULL;
+
+ if (argc > 2 && strcmp(argv[1], "--prefix") == 0) {
+ prefix = argv[2];
+ argc -= 2;
+ argv += 2;
+ }
+
if (argc < 2) {
- fprintf(stderr, "usage: %1$s --tasks <pid>\n"
- " %1$s --fds <pid>\n"
+ fprintf(stderr, "usage: %1$s [--prefix <prefix>] --tasks <pid>\n"
+ " %1$s [--prefix <prefix>] --fds <pid>\n"
" %1$s --is-procfs [<dir>]\n"
- " %1$s --processes [---name <name>] [--uid <uid>]\n"
- " %1$s --one <pid>\n"
- " %1$s --stat-nth <pid> <n>\n",
+ " %1$s --processes [--name <name>] [--uid <uid>]\n"
+ " %1$s [--prefix <prefix>] --one <pid>\n"
+ " %1$s [--prefix <prefix>] --stat-nth <pid> <n>\n",
program_invocation_short_name);
return EXIT_FAILURE;
}
if (strcmp(argv[1], "--tasks") == 0)
- return test_tasks(argc - 1, argv + 1);
+ return test_tasks(argc - 1, argv + 1, prefix);
if (strcmp(argv[1], "--fds") == 0)
- return test_fds(argc - 1, argv + 1);
+ return test_fds(argc - 1, argv + 1, prefix);
if (strcmp(argv[1], "--processes") == 0)
return test_processes(argc - 1, argv + 1);
if (strcmp(argv[1], "--is-procfs") == 0)
return test_isprocfs(argc - 1, argv + 1);
if (strcmp(argv[1], "--one") == 0)
- return test_one_process(argc - 1, argv + 1);
+ return test_one_process(argc - 1, argv + 1, prefix);
if (strcmp(argv[1], "--stat-nth") == 0)
- return test_process_stat_nth(argc - 1, argv + 1);
+ return test_process_stat_nth(argc - 1, argv + 1, prefix);
return EXIT_FAILURE;
}
return ret;
}
+int sysfs_get_address_bits(struct path_cxt *pc)
+{
+ int rc;
+ int address_bits;
+
+ rc = ul_path_scanf(pc, _PATH_SYS_ADDRESS_BITS, "%d", &address_bits);
+ if (rc < 0)
+ return rc;
+ if (address_bits < 0)
+ return -EINVAL;
+ return address_bits;
+}
+
#ifdef TEST_PROGRAM_SYSFS
#include <errno.h>
chain = sysfs_blkdev_get_devchain(pc, path, sizeof(path));
- printf(" SUBSUSTEMS:\n");
+ printf(" SUBSYSTEMS:\n");
while (chain && sysfs_blkdev_next_subsystem(pc, chain, &sub) == 0) {
printf("\t%s\n", sub);
#define BLKID_MAG_LASTOFFSET(_mag) \
(BLKID_MAG_OFFSET(_mag) - (BLKID_MAG_SECTOR(_mag) << 9))
+static uint16_t bsd_checksum(const struct bsd_disklabel *l)
+{
+ uint16_t v, csum = 0;
+ const char *end = (const char *) (l + 1);
+
+ for (const char *c = (const char *) l; c < end; c += sizeof(uint16_t)) {
+ memcpy(&v, c, sizeof(v));
+ csum ^= v;
+ }
+ return csum ^ le16_to_cpu(l->d_checksum);
+}
+
static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
{
struct bsd_disklabel *l;
l = (struct bsd_disklabel *) (data + BLKID_MAG_LASTOFFSET(mag));
+ if (!blkid_probe_verify_csum(pr, bsd_checksum(l), le16_to_cpu(l->d_checksum))) {
+ rc = BLKID_PROBE_NONE;
+ goto nothing;
+ }
+
ls = blkid_probe_get_partlist(pr);
if (!ls)
goto nothing;
offsetof(struct gpt_header, header_crc32),
sizeof(h->header_crc32));
- if (crc != le32_to_cpu(h->header_crc32)) {
+ if (!blkid_probe_verify_csum(pr, crc, le32_to_cpu(h->header_crc32))) {
DBG(LOWPROBE, ul_debug("GPT header corrupted"));
return NULL;
}
goto nothing;
}
- if (sgi_pt_checksum(l)) {
+ if (!blkid_probe_verify_csum(pr, sgi_pt_checksum(l), 0)) {
DBG(LOWPROBE, ul_debug(
"detected corrupted sgi disk label -- ignore"));
goto nothing;
goto nothing;
}
- if (sun_pt_checksum(l)) {
+ if (!blkid_probe_verify_csum(pr, sun_pt_checksum(l), 0)) {
DBG(LOWPROBE, ul_debug(
"detected corrupted sun disk label -- ignore"));
goto nothing;
* Copyright (C) 2001 by Andreas Dilger
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
* Copyright (C) 2008 Karel Zak <kzak@redhat.com>
- * Copyright (C) 2012 Milan Broz <mbroz@redhat.com>
+ * Copyright (C) 2012 Milan Broz <gmazyland@gmail.com>
*
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
(uint64_t)nvs_strlen + sizeof(*nvs) > max_value_size)
return;
- DBG(LOWPROBE, ul_debug("nvstring: type %u string %*s\n",
+ DBG(LOWPROBE, ul_debug("nvstring: type %u string %*s",
nvs_type, nvs_strlen, nvs->nvs_string));
blkid_probe_set_label(pr, nvs->nvs_string, nvs_strlen);
if (nvu_type != DATA_TYPE_UINT64)
return;
- DBG(LOWPROBE, ul_debug("nvuint64: type %u value %"PRIu64"\n",
+ DBG(LOWPROBE, ul_debug("nvuint64: type %u value %"PRIu64,
nvu_type, nvu_value));
blkid_probe_sprintf_value(pr, "UUID_SUB",
if (nvu_type != DATA_TYPE_UINT64)
return;
- DBG(LOWPROBE, ul_debug("nvuint64: type %u value %"PRIu64"\n",
+ DBG(LOWPROBE, ul_debug("nvuint64: type %u value %"PRIu64,
nvu_type, nvu_value));
blkid_probe_sprintf_uuid(pr, (unsigned char *) &nvu_value,
if (!p)
return;
- DBG(LOWPROBE, ul_debug("zfs_extract: nvlist offset %jd\n",
+ DBG(LOWPROBE, ul_debug("zfs_extract: nvlist offset %jd",
(intmax_t)offset));
nvl = (struct nvlist *) p;
goto cont;
}
- DBG(LOWPROBE, ul_debug("left %zd nvp_size %u\n",
+ DBG(LOWPROBE, ul_debug("left %zd nvp_size %u",
left, nvp_size));
/* nvpair fits in buffer and name fits in nvpair? */
break;
DBG(LOWPROBE,
- ul_debug("nvlist: size %u, namelen %u, name %*s\n",
+ ul_debug("nvlist: size %u, namelen %u, name %*s",
nvp_size, nvp_namelen, nvp_namelen,
nvp->nvp_name));
*ub_offset = offset;
*swap_endian = 0;
found++;
- DBG(LOWPROBE, ul_debug("probe_zfs: found little-endian uberblock at %jd\n", (intmax_t)offset >> 10));
+ DBG(LOWPROBE, ul_debug("probe_zfs: found little-endian uberblock at %jd", (intmax_t)offset >> 10));
}
if (ub->ub_magic == swab_magic) {
*ub_offset = offset;
*swap_endian = 1;
found++;
- DBG(LOWPROBE, ul_debug("probe_zfs: found big-endian uberblock at %jd\n", (intmax_t)offset >> 10));
+ DBG(LOWPROBE, ul_debug("probe_zfs: found big-endian uberblock at %jd", (intmax_t)offset >> 10));
}
}
void *label;
loff_t blk_align = (pr->size % (256 * 1024ULL));
- DBG(PROBE, ul_debug("probe_zfs\n"));
+ DBG(PROBE, ul_debug("probe_zfs"));
/* Look for at least 4 uberblocks to ensure a positive match */
for (label_no = 0; label_no < 4; label_no++) {
switch(label_no) {
static int probe_dm_tp(blkid_probe pr,
const struct blkid_idmag *mag __attribute__((__unused__)))
{
- const char *paths[] = {
+ const char * const paths[] = {
"/usr/local/sbin/dmsetup",
"/usr/sbin/dmsetup",
"/sbin/dmsetup"
/*
* ioctl topology values
*/
-static struct topology_val {
+static const struct topology_val {
long ioc;
size_t i;
for (i = 0; i < ARRAY_SIZE(topology_vals); i++) {
- struct topology_val *val = &topology_vals[i];
+ const struct topology_val *val = &topology_vals[i];
int rc = 1;
unsigned int data;
static int probe_lvm_tp(blkid_probe pr,
const struct blkid_idmag *mag __attribute__((__unused__)))
{
- const char *paths[] = {
+ const char * const paths[] = {
"/usr/local/sbin/lvdisplay",
"/usr/sbin/lvdisplay",
"/sbin/lvdisplay"
/*
* Sysfs topology values (since 2.6.31, May 2009).
*/
-static struct topology_val {
+static const struct topology_val {
/* /sys/dev/block/<maj>:<min>/<ATTR> */
const char *attr;
rc = 1; /* nothing (default) */
for (i = 0; i < ARRAY_SIZE(topology_vals); i++) {
- struct topology_val *val = &topology_vals[i];
+ const struct topology_val *val = &topology_vals[i];
int ok = ul_path_access(pc, F_OK, val->attr) == 0;
rc = 1; /* nothing */
dependencies : [realtime_libs],
install : false)
+lib__mount_deps = [
+ lib_selinux,
+ get_option('cryptsetup-dlopen').enabled() ? lib_dl : lib_cryptsetup,
+ realtime_libs
+]
lib_mount = library(
'mount',
link_whole : lib__mount,
link_args : ['-Wl,--version-script=@0@'.format(libmount_sym_path)],
link_with : [lib_common,
lib_blkid],
- dependencies : [lib_selinux,
- get_option('cryptsetup-dlopen').enabled() ? lib_dl : lib_cryptsetup,
- realtime_libs],
+ dependencies : lib__mount_deps,
install : build_libmount)
mount_dep = declare_dependency(link_with: lib_mount, include_directories: '.')
'src/' + libmount_test_src_override.get(libmount_test, libmount_test) + '.c',
include_directories : [dir_include, dir_libblkid],
link_with : [lib__mount, lib_common, lib_blkid_static],
- dependencies : [lib_cryptsetup],
+ dependencies : lib__mount_deps,
c_args : ['-DTEST_PROGRAM'],
)
# the test-setup expects the helpers in the toplevel build-directory
endif
if lib_selinux.found()
- chfn_chsh_sources += files(
- 'selinux_utils.c',
- 'selinux_utils.h',
- )
+ chfn_chsh_sources += selinux_utils_c
chfn_chsh_deps += [lib_selinux]
endif
mandir = join_paths(prefixdir, get_option('mandir'))
runstatedir = '/run'
execprefixdir = prefixdir
+sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
usrbin_exec_dir = join_paths(execprefixdir, bindir)
usrsbin_exec_dir = join_paths(execprefixdir, sbindir)
bash_completion = dependency('bash-completion', required : get_option('build-bash-completion'))
conf.set('bindir', bindir)
conf.set('sbindir', sbindir)
conf.set('runstatedir', runstatedir)
+conf.set('sysconfdir', sysconfdir)
conf.set('usrsbin_execdir', usrsbin_exec_dir)
conf.set('docdir', docdir)
conf.set_quoted('_PATH_SYSCONFSTATICDIR', sysconfstaticdir)
conf.set('HAVE_LIBECONF', lib_econf.found() ? 1 : false)
lib_audit = dependency(
- 'libaudit',
+ 'audit',
required : get_option('audit'))
conf.set('HAVE_LIBAUDIT', lib_audit.found() ? 1 : false)
systemdsystemunitdir = systemd.get_variable(pkgconfig : 'systemdsystemunitdir')
endif
+sysvinit = get_option('sysvinit').enabled()
+sysvinitrcdir = sysconfdir + '/init.d'
+
chfn_chsh_password = get_option('chfn-chsh-password') or lib_user.found()
conf.set('CHFN_CHSH_PASSWORD', chfn_chsh_password ? 1 : false)
'setarch',
setarch_sources,
include_directories : includes,
+ link_with : [lib_common],
install_dir : usrbin_exec_dir,
install : true)
exes += exe
'namei',
namei_sources,
include_directories : includes,
+ dependencies : [lib_selinux],
install_dir : usrbin_exec_dir,
install : true)
exes += exe
option('magic', type : 'feature')
option('econf', type : 'feature')
option('systemd', type : 'feature')
+option('sysvinit', type : 'feature', value : 'disabled',
+ description : 'build and install sysvinit startup scripts')
option('btrfs', type : 'feature')
option('widechar', type : 'feature',
description : 'compile with wide character support')
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt_long (argc, argv, "a:d:hl:o:", longopts, NULL)) != -1) {
+ while ((c = getopt_long (argc, argv, "a:d:hl:o:V", longopts, NULL)) != -1) {
switch (c) {
case 'a':
break;
free(p->model);
free(p->partflags);
free(p->idlink);
+ free(p->revision);
free(p->mode);
free(p->owner);
normalize_whitespace((unsigned char *) prop->serial);
}
+ if ((data = udev_device_get_property_value(dev, "ID_REVISION")))
+ prop->revision = xstrdup(data);
+
if ((data = udev_device_get_property_value(dev, "ID_MODEL_ENC"))) {
prop->model = xstrdup(data);
unhexmangle_string(prop->model);
else if (lookup(buf, "ID_SCSI_SERIAL", &prop->serial)) ;
else if (lookup(buf, "ID_SERIAL_SHORT", &prop->serial)) ;
else if (lookup(buf, "ID_SERIAL", &prop->serial)) ;
+ else if (lookup(buf, "ID_REVISION", &prop->revision)) ;
/* lsblk specific */
else if (lookup(buf, "MODE", &prop->mode)) ;
== AUTHORS
-mailto:mbroz@redhat.com[Milan Broz],
+mailto:gmazyland@gmail.com[Milan Broz],
mailto:kzak@redhat.com[Karel Zak]
== SEE ALSO
* lsblk(8) - list block devices
*
* Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
- * Written by Milan Broz <mbroz@redhat.com>
+ * Written by Milan Broz <gmazyland@gmail.com>
* Karel Zak <kzak@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
trans = "nvme";
} else if (strncmp(dev->name, "vd", 2) == 0)
trans = "virtio";
+ else if (strncmp(dev->name, "mmcblk", 6) == 0)
+ trans = "mmc";
return trans;
}
}
break;
case COL_REV:
- if (!device_is_partition(dev) && dev->nslaves == 0)
- ul_path_read_string(dev->sysfs, &str, "device/rev");
+ if (!device_is_partition(dev) && dev->nslaves == 0) {
+ prop = lsblk_device_get_properties(dev);
+ if (prop && prop->revision)
+ str = xstrdup(prop->revision);
+ else
+ ul_path_read_string(dev->sysfs, &str, "device/rev");
+ }
break;
case COL_VENDOR:
if (!device_is_partition(dev) && dev->nslaves == 0)
add_uniq_column(COL_TYPE);
add_uniq_column(COL_MODEL);
add_uniq_column(COL_SERIAL);
+ add_uniq_column(COL_REV);
add_uniq_column(COL_TRANSPORT);
add_uniq_column(COL_RQ_SIZE);
add_uniq_column(COL_MQ);
/*
* Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
- * Written by Milan Broz <mbroz@redhat.com>
+ * Written by Milan Broz <gmazyland@gmail.com>
* Karel Zak <kzak@redhat.com>
*/
#ifndef UTIL_LINUX_LSBLK_H
char *serial; /* disk serial number */
char *model; /* disk model */
char *idlink; /* /dev/disk/by-id/<name> */
+ char *revision; /* firmware revision/version */
/* lsblk specific (for --sysroot only) */
char *owner; /* user name */
uuidd_socket,
install_dir : systemdsystemunitdir)
endif
+if build_uuidd and sysvinit
+ uuidd_rc = configure_file(
+ input : 'uuidd.rc.in',
+ output : 'uuidd.rc',
+ configuration : conf)
+ install_data(
+ uuidd_rc,
+ install_mode : 'rwxr-xr-x',
+ install_dir : sysvinitrcdir)
+endif
blkid_sources = files(
'blkid.c',
== OPTIONS
*-s*, *--symlink*::
-Do not rename a symlink but its target.
+Do not rename a symlink but change where it points.
*-v*, *--verbose*::
Show which files were renamed, if any.
The renaming has no safeguards by default or without any one of the options *--no-overwrite*, *--interactive* or *--no-act*. If the user has permission to rewrite file names, the command will perform the action without any questions. For example, the result can be quite drastic when the command is run as root in the _/lib_ directory. Always make a backup before running the command, unless you truly know what you are doing.
+== EDGE CASES
+
+If the _expression_ is empty, then by default _replacement_ will be added to the start of the filename. With *--all*, _replacement_ will be inserted in between every two characters of the filename, as well as at the start and end.
+
+Normally, only the final path component of a filename is updated. But if either _expression_ or _replacement_ contains a _/_, the full path is updated. This can cause a file to be moved between folders. Creating folders, and moving files between filesystems, is not supported. With *--symlink*, the update is always applied to the link's full path.
+
== INTERACTIVE MODE
As most standard utilities rename can be used with a terminal device (tty in short) in canonical mode, where the line is buffered by the tty and you press ENTER to validate the user input. If you put your tty in cbreak mode however, rename requires only a single key press to answer the prompt. To set cbreak mode, run for example:
MANPAGES += sys-utils/setarch.8
dist_noinst_DATA += sys-utils/setarch.8.adoc
setarch_SOURCES = sys-utils/setarch.c
+setarch_LDADD = $(LDADD) libcommon.la
SETARCH_LINKS = uname26 linux32 linux64
printf(_("The RTC parameter 0x%jx is set to 0x%jx.\n"),
(uintmax_t) id, (uintmax_t) value);
+ return 0;
} else if (ctl->param_set_option) {
if (ctl->testing)
#include "nls.h"
#include "c.h"
#include "closestream.h"
+#include "sysfs.h"
#ifndef HAVE_PERSONALITY
# include <syscall.h>
if (!strcmp(un.machine, transitions[i].target_arch))
break;
if (transitions[i].perval < 0) {
- unsigned long wrdsz = CHAR_BIT * sizeof(void *);
+ int wrdsz = sysfs_get_address_bits(NULL);
+ if (wrdsz < 0)
+ wrdsz = CHAR_BIT * sizeof(void *);
if (wrdsz == 32 || wrdsz == 64) {
/* fill up the place holder */
transitions[i].perval = wrdsz == 32 ? PER_LINUX32 : PER_LINUX;
TS_HELPER_LAST_FUZZ="${ts_helpersdir}test_last_fuzz"
TS_HELPER_MKFDS="${ts_helpersdir}test_mkfds"
TS_HELPER_BLKID_FUZZ="${ts_helpersdir}test_blkid_fuzz"
+TS_HELPER_PROCFS="${ts_helpersdir}test_procfs"
# paths to commands
TS_CMD_ADDPART=${TS_CMD_ADDPART:-"${ts_commandsdir}addpart"}
--- /dev/null
+1
+ UID: [redacted]
+ CMDLINE: './test'
+ COMM: 'test'
+2
+ UID: [redacted]
+ CMDLINE: './foo
+bar'
+ COMM: 'foo
+bar'
+3
+ UID: [redacted]
+ CMDLINE: './foo )bar'
+ COMM: 'foo )bar'
--- /dev/null
+1: 1th 373850
+1: 4th 373752
+2: 1th 1583
+2: 4th 1165
+3: 1th 4102
+3: 4th 1165
--- /dev/null
+test_procfs: read 2th number failed: Invalid argument
+test_procfs: read 3th number failed: Invalid argument
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2022 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="procfs library"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_PROCFS"
+
+test_data="$TS_SELF/procfs-data"
+test_cmd() {
+ "$TS_HELPER_PROCFS" --prefix "$test_data" "$@" \
+ 2>> "$TS_ERRLOG" \
+ | sed -e 's/ UID: .*/ UID: [redacted]/' \
+ >> "$TS_OUTPUT"
+}
+
+ts_init_subtest "one-process"
+
+test_cmd --one 1
+test_cmd --one 2
+test_cmd --one 3
+
+ts_finalize_subtest
+
+
+ts_init_subtest "stat-nth"
+
+test_cmd --stat-nth 1 1
+test_cmd --stat-nth 1 2
+test_cmd --stat-nth 1 3
+test_cmd --stat-nth 1 4
+
+test_cmd --stat-nth 2 1
+test_cmd --stat-nth 2 4
+
+test_cmd --stat-nth 3 1
+test_cmd --stat-nth 3 4
+
+ts_finalize_subtest
+
+ts_finalize
--- /dev/null
+373850 (test) S 373752 373850 373752 34835 373850 4194304 83 0 0 0 0 0 0 0 20 0 1 0 6164479 2543616 320 18446744073709551615 94138801930240 94138801930657 140720370008720 0 0 0 0 0 0 1 0 0 17 1 0 0 0 0 0 94138801941968 94138801942568 94138832138240 140720370011239 140720370011246 140720370011246 140720370012145 0
--- /dev/null
+1583 (foo
+bar) S 1165 1583 1165 34818 1583 4194304 82 0 0 0 0 0 0 0 20 0 1 0 17487 2543616 215 18446744073709551615 93858497511424 93858497511841 140729173273328 0 0 0 0 0 0 1 0 0 17 0 0 0 0 0 0 93858497523152 93858497523752 93858527924224 140729173281886 140729173281896 140729173281896 140729173282798 0
--- /dev/null
+4102 (foo )bar) S 1165 4102 1165 34818 4102 4194304 80 0 0 0 0 0 0 0 20 0 1 0 61909 2543616 215 18446744073709551615 94697631760384 94697631760801 140728832669632 0 0 0 0 0 0 1 0 0 17 0 0 0 0 0 0 94697631772112 94697631772712 94697662554112 140728832670811 140728832670822 140728832670822 140728832671725 0
ts_skip "ioctl not supported"
fi
-# 32bit userspace (NS ioctls) does not work as expected with 64bit kernel
-WORDSIZE=$($TS_HELPER_SYSINFO WORDSIZE)
-if [ $WORDSIZE -eq 32 ]; then
- uname -m | grep -q 64
- if [ $? -eq 0 ]; then
- TS_KNOWN_FAIL="yes"
- fi
-fi
-
$TS_CMD_UNSHARE --user --pid --mount-proc --fork true &> /dev/null || ts_skip "no namespace support"
ts_cd "$TS_OUTDIR"