summaryrefslogtreecommitdiff
path: root/tools/lvm.c
Commit message (Collapse)AuthorAgeFilesLines
* shell: add pre-cmd log report object type and enable lastlog for itPeter Rajnoha2022-08-221-4/+7
| | | | | | | If we failed or logged anything before we actually execute given command in lvm shell, we couldn't report the log using lastlog command after. This patch adds specific 'pre-cmd' log report object type to identify such log messages and enables lastlog to report even this log.
* shell: also output error message about max number of args hit with JSON formatPeter Rajnoha2022-08-081-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If using JSON format for lvm shell's output, the error message about exceeding the maximum number of arguments was not reported on output if this condition was ever hit. This is because the JSON format (as well as any other future format) requires extra formatting compared to "basic" format and so it also requires extra calls when it comes to reporting. The report needs to be added to a report group and then popped and put on output with specialized "dm_report_group_output_and_pop_all". This "output and pop" is normally executed after we execute the command in the lvm shell. When we didn't get to the command exection at all because some precondition was not met (like hitting the limit for the number of arguments for the command here), we skipped this important call and so there was no log report output. Right now, it's only this exact error message for which we need to call "output and pop" directly, all the other error messages are about initializing and setting the log report itself which we can't report obviously. Before this patch: lvm> pvs 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 lvm> With this patch applied: lvm> pvs 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 { "log": [ {"log_seq_num":"1", "log_type":"error", "log_context":"shell", "log_object_type":"cmd", "log_object_name":"", "log_object_id":"", "log_object_group":"", "log_object_group_id":"", "log_message":"Too many arguments, sorry.", "log_errno":"-1", "log_ret_code":"0"} ] } If there's any other error message in the future before we execute the command itself, we also need to call the "output and pop" directly.
* cov: ignoringZdenek Kabelac2021-09-271-0/+1
|
* lvm: Fix editline compilationMarian Csontos2021-03-221-1/+0
|
* lvm: add readline alternative editlineBastian Germann2020-09-291-8/+13
| | | | | | | | | | | | | LVM2 is distributed under GPLv2 only. The readline library changed its license long ago to GPLv3. Given that those licenses are incompatible and you follow the FSF in their interpretation that dynamically linking creates a derivative work, distributing LVM2 linked against a current readline version might be legally problematic. Add support for the BSD licensed editline library as an alternative for readline. Link: https://thrysoee.dk/editline
* debug: tracing error pathZdenek Kabelac2017-06-271-1/+2
|
* commands: combine duplicate arrays for opt and valDavid Teigland2017-03-081-4/+4
| | | | | | command.c and lvmcmdline.c each had a full array defining all options and values. This duplication was not removed when the command.c code was merged into the run time.
* lvm shell: clear argv for each commandDavid Teigland2017-02-131-1/+4
|
* commands: new method for defining commandsDavid Teigland2017-02-131-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . Define a prototype for every lvm command. . Match every user command with one definition. . Generate help text and man pages from them. The new file command-lines.in defines a prototype for every unique lvm command. A unique lvm command is a unique combination of: command name + required option args + required positional args. Each of these prototypes also includes the optional option args and optional positional args that the command will accept, a description, and a unique string ID for the definition. Any valid command will match one of the prototypes. Here's an example of the lvresize command definitions from command-lines.in, there are three unique lvresize commands: lvresize --size SizeMB LV OO: --alloc Alloc, --autobackup Bool, --force, --nofsck, --nosync, --noudevsync, --reportformat String, --resizefs, --stripes Number, --stripesize SizeKB, --poolmetadatasize SizeMB OP: PV ... ID: lvresize_by_size DESC: Resize an LV by a specified size. lvresize LV PV ... OO: --alloc Alloc, --autobackup Bool, --force, --nofsck, --nosync, --noudevsync, --reportformat String, --resizefs, --stripes Number, --stripesize SizeKB ID: lvresize_by_pv DESC: Resize an LV by specified PV extents. FLAGS: SECONDARY_SYNTAX lvresize --poolmetadatasize SizeMB LV_thinpool OO: --alloc Alloc, --autobackup Bool, --force, --nofsck, --nosync, --noudevsync, --reportformat String, --stripes Number, --stripesize SizeKB OP: PV ... ID: lvresize_pool_metadata_by_size DESC: Resize a pool metadata SubLV by a specified size. The three commands have separate definitions because they have different required parameters. Required parameters are specified on the first line of the definition. Optional options are listed after OO, and optional positional args are listed after OP. This data is used to generate corresponding command definition structures for lvm in command-lines.h. usage/help output is also auto generated, so it is always in sync with the definitions. Every user-entered command is compared against the set of command structures, and matched with one. An error is reported if an entered command does not have the required parameters for any definition. The closest match is printed as a suggestion, and running lvresize --help will display the usage for each possible lvresize command. The prototype syntax used for help/man output includes required --option and positional args on the first line, and optional --option and positional args enclosed in [ ] on subsequent lines. command_name <required_opt_args> <required_pos_args> [ <optional_opt_args> ] [ <optional_pos_args> ] Command definitions that are not to be advertised/suggested have the flag SECONDARY_SYNTAX. These commands will not be printed in the normal help output. Man page prototypes are also generated from the same original command definitions, and are always in sync with the code and help text. Very early in command execution, a matching command definition is found. lvm then knows the operation being done, and that the provided args conform to the definition. This will allow lots of ad hoc checking/validation to be removed throughout the code. Each command definition can also be routed to a specific function to implement it. The function is associated with an enum value for the command definition (generated from the ID string.) These per-command-definition implementation functions have not yet been created, so all commands currently fall back to the existing per-command-name implementation functions. Using per-command-definition functions will allow lots of code to be removed which tries to figure out what the command is meant to do. This is currently based on ad hoc and complicated option analysis. When using the new functions, what the command is doing is already known from the associated command definition.
* report: add report_reset_cmdlog_seqnum and call it for each new cmd executed ↵Peter Rajnoha2016-08-091-0/+1
| | | | in lvm shell
* lvm: shell: honor log/command_log_selection as default and reset to this ↵Peter Rajnoha2016-08-091-1/+13
| | | | value after lastlog
* lvm: shell: extend log report to cover whole lvm shell's main loopPeter Rajnoha2016-08-091-12/+52
| | | | | | | When lvm commands are executed in lvm shell, we cover the whole lvm command execution within this shell now. That means, all messages logged and status caught during each command execution is now recorded in the log report, including overall command's return code.
* refactor: move report grouping and log reporting handles from ↵Peter Rajnoha2016-08-091-5/+5
| | | | | | | | | processing_handle to cmd_context With patches that will follow, this will make it possible to widen log report coverage when commands are executed from lvm shell so the amount of messages that may end up in stderr/stdout instead of log report are minimized.
* shell: also collect last command's return code for subsequent 'lastlog' ↵Peter Rajnoha2016-08-091-2/+35
| | | | | | | | | invocation Add new log_context=shell and with log_object_type=cmd and log_object_name=<command_name> for command log report to collect overall return code from last command (this is reported under log_type=status).
* tools: add 'lvm lastlog' command for interactive query and display of last ↵Peter Rajnoha2016-06-201-0/+6
| | | | | | | | command's log If we're running in lvm shell, we can keep last command's log report for further query with possible different selection criteria for easy log lookup.
* refactor: move 'interactive' field from struct command_line to struct ↵Peter Rajnoha2016-06-201-1/+2
| | | | cmd_context as 'is_interactive' switch
* doc: change fsf addressZdenek Kabelac2016-01-211-1/+1
| | | | | Hmm rpmlint suggest fsf is using a different address these days, so lets keep it up-to-date
* include: Standardise around new tool.h.Alasdair G Kergon2015-07-061-0/+1
|
* lvm: move hyphen mangling codeZdenek Kabelac2015-06-191-25/+0
| | | | | | | Relocate hyphen code from lvm main into lvm_run_command() so all command and library user will have it. Update WHATS_NEW with missing changes.
* Ignore hyphens in long option namesDavid Teigland2015-06-161-0/+25
| | | | | | | | | | | | | | The hyphens are removed from long option names before being read. This means that: - Option name specifications in args.h must not include hyphens. (The hyphen in 'use-policies' is removed.) - A user can include hyphens anywhere in the option name. All the following are equivalent: --vgmetadatacopies, --vg-metadata-copies, --v-g-m-e-t-a-d-a-t-a-c-o-p-i-e-s-
* readline: switch to new-style readline typedefZdenek Kabelac2014-03-061-1/+2
| | | | | | | | | | | | | | | Based on patch: https://www.redhat.com/archives/lvm-devel/2014-March/msg00015.html The CPPFunction typedef (among others) have been deprecated in favour of specific prototyped typedefs since readline 4.2 (circa 2001). It's been working since because compatibility typedefs have been in place until they where removed in the recent readline 6.3 release. Switch to the new style to avoid build breakage. But also add full backward compatibility with define. Signed-off-by: Gustavo Zacarias <gustavo zacarias com ar>
* config: add profile arg to find_config_tree_intPeter Rajnoha2013-07-021-1/+1
|
* Revert "cleanup: simplify option matching function"Alasdair G Kergon2013-04-131-5/+12
| | | | | | | | This reverts commit 0396ade38b88431d959ce02fac689306a2c47786. The original code also handled len==1, which the new code doesn't. Press <TAB> in the lvm shell to get a list of the possible flag completions for a single hyphen.
* config: refer to config nodes using assigned IDsPeter Rajnoha2013-03-061-2/+1
| | | | | | | | | | | | | | | For example, the old call and reference: find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR) ...now becomes: find_config_tree_str(cmd, devices_dir_CFG) So we're referring to the named configuration ID instead of passing the configuration path and the default value is taken from central config definition in config_settings.h automatically.
* cleanup: simplify option matching functionZdenek Kabelac2012-12-151-12/+5
| | | | | Avoid using sprintf and strncmp call, when we really want to compare just one character.
* config: add silent modeAlasdair G Kergon2012-08-251-0/+1
| | | | | | | | | | | | | | | | Accept -q as the short form of --quiet. Suppress non-essential standard output if -q is given twice. Treat log/silent in lvm.conf as equivalent to -qq. Review all log_print messages and change some to log_print_unless_silent. When silent, the following commands still produce output: dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay, pvs, version, vgcfgrestore -l, vgdisplay, vgs. [Needs checking.] Non-essential messages are shifted from log level 4 to log level 5 for syslog and lvm2_log_fn purposes.
* Remove unneeded assignmentsZdenek Kabelac2012-02-081-1/+1
| | | | Variables have (or will have) those values set.
* Thin remove unused defineZdenek Kabelac2011-11-121-1/+0
| | | | | | | Remove DM_THIN_ERROR_DEVICE_ID from API. Remove API warning. Drop code that was using DM_THIN_ERROR_DEVICE_ID (already commented) Remove debug message which slipped in through some previous commit.
* Support repetition of --addtag and --deltag arguments.Alasdair Kergon2010-11-111-2/+2
| | | | | Add infrastructure for specific cmdline arguments to be repeated in groups. Split the_args cmdline arguments and values into arg_props and arg_values.
* Fix potential NULL pointer dereferenceZdenek Kabelac2010-10-251-3/+3
| | | | | | Makes clang happier as it covers all code paths and avoids NULL pointer dereference through the 'com' pointer (which is NULL by default static initialisation).
* Use __attribute__ consistently throughout.Alasdair Kergon2010-07-091-1/+1
|
* Fix lvm shell crash when input is entirely whitespace. (Xinwei Hu)Alasdair Kergon2010-07-011-0/+3
|
* #define an INTERNAL_ERROR macro and use it throughout LVM.Petr Rockai2009-12-161-1/+1
|
* Create global is_static() to eliminate from the library init function.Dave Wysochanski2008-12-181-1/+1
| | | | | | | | Very simple / crude method of removing 'is_static' from initialization. Why should we require an application tell us whether it is linked statically or dynamically to libLVM? If the application is linked statically, but libraries exist and dlopen() calls succeed, why do we care if it's statically linked?
* post-releaseAlasdair Kergon2008-06-061-0/+4
|
* back out unnecessary changes for this releaseAlasdair Kergon2008-06-061-4/+0
|
* suppress warning on silent failure with ECMD_PROCESSEDAlasdair Kergon2008-06-031-1/+1
|
* In script-processing mode, stop if any command fails.Alasdair Kergon2008-05-301-0/+4
| | | | Warn if command exits with non-zero status code without a prior log_error.
* Fix mirror log name construction during lvconvert. (2.02.30)Alasdair Kergon2008-01-311-1/+2
| | | | | | Make monitor_dev_for_events recurse through the stack of LVs. Clean up some more compiler warnings. Add mirror names test script.
* Some whitespace tidy-ups.Alasdair Kergon2008-01-301-1/+1
|
* Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1.Alasdair Kergon2007-08-201-1/+1
|
* Exclude readline support from lvm.staticAlasdair Kergon2007-02-141-0/+224
|
* Static binary invokes dynamic binary if appropriate.Alasdair Kergon2005-02-181-1/+1
|
* More build fixesAlasdair Kergon2004-04-061-1/+2
|
* Update copyright notices.Alasdair Kergon2004-03-301-1/+9
|
* Move main() into separate file.Alasdair Kergon2004-03-261-1228/+2
|
* Indent; _init -> _init_lvmAlasdair Kergon2004-03-261-8/+6
|
* Rebaseline internal verbose level.Alasdair Kergon2004-03-261-1/+1
|
* rename config file vars & always use / as separatorAlasdair Kergon2004-03-081-16/+16
|
* host tagsAlasdair Kergon2004-03-081-2/+5
|