summaryrefslogtreecommitdiffstats
path: root/misc-utils/blkid.c
Commit message (Collapse)AuthorAgeFilesLines
* blkid: improve strcpy() usage [coverity scan]Karel Zak2019-05-161-3/+8
| | | | | | | The old deprecated list output format ("-o list") copies gettex string into fixed buffer, that's really bad idea. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: add print_version() macroKarel Zak2019-04-161-8/+3Star
| | | | | | | | | | | Let's consolidate the version printing code. It also seems better to use exit() after --version, because it's handled in different way by ASAN. It's strange, but ASAN reports leaks after return in main(). Note that we do not use free-before-exit. Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: fix usage()Karel Zak2018-11-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: make PART_ENTRY_* tags optional (add --no-part-details)Karel Zak2018-11-291-4/+11
| | | | | | | | | | | | | | | | | | blkid(8) returns information from partition table also for empty partitions. This is necessary for example for udev, but it could be confusing if you care about on-device content only. Default: # blkid -p /dev/md0p1; echo $? /dev/md0p1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="6d8796b1-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="204800" PART_ENTRY_DISK="9:0" 0 With --no-part-details: # blkid -p /dev/md0p1 --no-part-details; echo $? 2 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653413 Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: fix compiler warnings [-Wcast-qual]Karel Zak2018-07-231-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: Encode any field which starts with LABEL in same way as LABEL fieldPali Rohár2017-11-251-1/+1
| | | | | | | This applies also for LABEL_FATBOOT which contains bytes according to DOS code page and therefore does not contain valid UTF-8 sequence. Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(int)Ruediger Meier2017-06-261-4/+4
| | | | | | | This patch is trivial and changes nothing, because we were always using usage(0). Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'fix-exit-codes' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-261-1/+4
|\ | | | | | | | | | | | | | | | | * 'fix-exit-codes' of https://github.com/rudimeier/util-linux: misc: fix optutils.h related exit codes misc: fix xalloc.h related exit codes misc: fix more strutils related exit codes lib: fix strutils.h, remove STRTOXX_EXIT_CODE misc: fix some broken exit codes
| * misc: fix xalloc.h related exit codesRuediger Meier2017-06-221-0/+2
| | | | | | | | | | | | | | | | | | Found by: grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \ $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c")) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * lib: fix strutils.h, remove STRTOXX_EXIT_CODERuediger Meier2017-06-221-1/+2
| | | | | | | | | | | | | | | | | | As discussed on the mailing list. We fix all places where the non-working define STRTOXX_EXIT_CODE was used. Regarding tunelp, also see 7e3c80a7. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | blkid: use errtryhelp instead of errtryhRuediger Meier2017-06-221-4/+4
|/ | | | | | We have a --help option and this is preferred. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch '2017wk16' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2017-05-091-30/+53
|\ | | | | | | | | | | | | | | | | | | | | | | | | * '2017wk16' of git://github.com/kerolasa/lelux-utiliteetit: chfn, chsh: use readline(3) to receive user input findfs: use getopt_long() to parse options logger: make month names, login name, and tag read-only objects sulogin: reduce vulnerability surface partx: add --list-types option libblkid: add blkid_partitions_get_name() docs: try to convince open(2) O_DIRECT rather than using raw device blkid: add long options lsipc: fix options parsing and sync with man page
| * blkid: add long optionsSami Kerola2017-05-031-30/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | This change attempts to make tab completion more reasonable by alloging memorizable option names. That also has positive impact to manual page, in which referrals to other options are now easier to understand. All short options are kept exactly as they were to avoid ABI breakage. The only exception is -f option that getopt(3) recognized, but was not found from anywhere else. The -f has been part of blkid since the initial commit. Commit: 51410fc6deb29cae54a2669aafabae6c49f964fc Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | blkid: fix return code when display the versionAlexey Gladkov2017-05-051-0/+1
|/ | | | Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
* blkid: fix compiler warning [-Wdiscarded-qualifiers]Karel Zak2017-03-241-5/+5
| | | | | | Let's also hide the show[] array in has_item(). Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: add control structSami Kerola2017-03-171-83/+88
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: simplify version option handlingSami Kerola2017-03-171-8/+2Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: add messages to translationsSami Kerola2017-03-131-74/+69Star
| | | | | | | | | | | | Without obvious reason blkid has managed to be part of this project for pretty long time without getting translations. Lets change that. In same go use the usual error printing facilities instead of fprintf(stderr, ...); [kzak@redhat.com: - use errtryh(), - cleanup "unsupported output format"] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: add curly braces to do-while statementSami Kerola2017-03-131-2/+2
| | | | | | | | | Some say people read do-while statements are easily as while statements and get wrong impression. This happens because do-whiles are not common. Adding braces should make it easier to read the code. Reference: http://www.spinics.net/lists/linux-kernel-janitors/msg02018.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* Use --help suggestion on invalid optionKarel Zak2016-12-191-3/+3
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* include/closestream: define exit codesKarel Zak2016-08-161-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* libblkid: use internally uint64_t for offsets and sizesKarel Zak2016-01-121-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: Pass default width to get_terminal_width()Boris Egorov2016-01-061-4/+2Star
| | | | | | | | | | Almost any code calling get_terminal_width() checks returned width for non-positive values and sets it to some default value (say, 80). So, let's pass this default value directly to the function. [kzak@redhat.com: - get_terminal_width() refactoring] Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid, uuidd, uuidgen: assume getopt.h and getopt.h are availableSami Kerola2015-10-091-6/+0Star
| | | | | | These headers are in use allover this project without issues. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: don't ignore info about partitions on non-formated devicesKarel Zak2015-05-211-15/+0Star
| | | | | | | | | | | | |  # blkid -p /dev/sdc1; echo $? 2 but libblkid provides information about partition, fixed version: # blkid -p /dev/sdc1; echo $? /dev/sdc1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="4c1e518c-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="1021952" PART_ENTRY_DISK="8:32" 0 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: care about unsafe chars in cacheKarel Zak2014-11-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The high-level libblkid API uses /run/blkid/blkid.tab cache to store probing results. The cache format is <device NAME="value" ...>devname</device> and unfortunately the cache code does not escape quotation marks: # mkfs.ext4 -L 'AAA"BBB' # cat /run/blkid/blkid.tab ... <device ... LABEL="AAA"BBB" ...>/dev/sdb1</device> such string is later incorrectly parsed and blkid(8) returns nonsenses. And for use-cases like # eval $(blkid -o export /dev/sdb1) it's also insecure. Note that mount, udevd and blkid -p are based on low-level libblkid API, it bypass the cache and directly read data from the devices. The current udevd upstream does not depend on blkid(8) output at all, it's directly linked with the library and all unsafe chars are encoded by \x<hex> notation. # mkfs.ext4 -L 'X"`/tmp/foo` "' /dev/sdb1 # udevadm info --export-db | grep LABEL ... E: ID_FS_LABEL=X__/tmp/foo___ E: ID_FS_LABEL_ENC=X\x22\x60\x2ftmp\x2ffoo\x60\x20\x22 Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: remove extra trailing spaces in outputKarel Zak2014-10-231-2/+3
| | | | | | | | | | | | | $ blkid | egrep -i 'sda.*label' | cat -A /dev/sda2: UUID="8382f307-fb43-489f-ab38-8d4cf37ca88c" SEC_TYPE="ext2" TYPE="ext3" LABEL="test" $ /dev/sda5: UUID="0b46d673-8c23-4709-b92c-3fdf460e1dd4" TYPE="ext3" LABEL="rescue" SEC_TYPE="ext2" $ /dev/sda6: UUID="cb9d814f-d885-435b-8e6d-ac17c0ac5aa1" TYPE="ext3" LABEL="root" $ /dev/sda8: UUID="1e2851bd-cc6f-4d72-bf9f-c6fa754155b1" TYPE="ext3" LABEL="data" SEC_TYPE="ext2" $ /dev/sda9: UUID="d16a2f42-9a50-4489-a788-8624c832a7f3" TYPE="ext3" LABEL="storage" SEC_TYPE="ext2" $ /dev/sda7: TYPE="swap" LABEL="swap" UUID="8393acfa-d4bd-40fc-8eb9-5ccd8d85e103" $ Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586179 Signed-off-by: Karel Zak <kzak@redhat.com>
* Revert "blkid: remove unused variable"Karel Zak2014-05-131-2/+2
| | | | This reverts commit 0fd4b8132587a264f1e0df46eec7c12bba68c752.
* blkid: remove unused variableSami Kerola2014-05-121-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: simple typoPhillip Susi2013-11-081-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: escape quotes in the outputKarel Zak2013-11-071-4/+8
| | | | | | | | | | | | | # e2label /dev/loop0 'La"bel' # blkid -p /dev/loop0 /dev/loop0: LABEL="La"bel" .... new version: /dev/loop0: LABEL="La\"bel" .... Reported-by: Phillip Susi <psusi@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: export ID_PART_TABLE_UUIDKarel Zak2013-06-131-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: fix typo in ID_FS_AMBIVALEN=Karel Zak2013-05-141-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid, hwclock, ldattach: use program_invocation_short_nameSami Kerola2013-04-261-3/+1Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: use xalloc everywhereKarel Zak2013-04-101-22/+4Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: use O_CLOEXECKarel Zak2013-04-031-1/+1
| | | | | | | ... to make "strace -e open blkid" for libblkid stuff without exceptions. Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: use xalloc.h when possibleSami Kerola2013-03-261-4/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: also accept -V for displaying version informationBenno Schulenberg2013-03-201-2/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: standardize reporting of program name plus package versionBenno Schulenberg2013-01-251-2/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* blkid: fix double free [coverity scan]Karel Zak2012-12-121-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: fix shadow declarationSami Kerola2012-07-261-4/+4
| | | | | | | misc-utils/blkid.c:402:15: warning: declaration of 'usage' shadows a global declaration [-Wshadow] misc-utils/blkid.c:63:13: warning: shadowed declaration is here [-Wshadow] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: use err_exclusive_options()Karel Zak2012-07-261-8/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: use exclusive_option()Sami Kerola2012-06-171-8/+12
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkid: fix realloc memory leak [cppcheck]Sami Kerola2012-06-111-1/+3
| | | | | | [misc-utils/blkid.c:367]: (error) Common realloc mistake: 'str' nulled but not freed upon failure Signed-off-by: Sami Kerola <kerolasa@iki.fi>