Reviewed by: Matthew Ahrens <mahr...@delphix.com> Reviewed by: Paul Dagnelie <p...@delphix.com> Reviewed by: Prashanth Sreenivasa <p...@delphix.com>
Currently, if you want to write to a kernel tunable using mdb, you need to use the /Z or /W flags to write 8 or 4 bytes respectively. If you use the wrong one, you will either overwrite only part of the tunable, or overrun the end of the tunable and zero out the next 4 bytes of memory. That second option in particular can be disastrous. Given that MDB knows the size of the tunables because it has CTF data, it would be nice if MDB supported a "smart write" format string that selected the size of the write based on the size of the thing being written to. It should fail or require a size be specified if we're writing to an area without a specific size. A new dcmd and a new format for writing are added to mdb. New format: - Looks like this -> [address]/z [value] - Writes the value in the address starting from the specified address - The size of the write is inferred by the CTF data of the symbol at the address provided - If no CTF data exist at the given address, the write fails New dcmd: - Looks like this -> [address]::write [value] - Works exactly like the format specifier above - For physical writes specify the -p argument (i.e. [address]\z [value]) - For object file writes specify the -o argument (i.e. [address]?z [value]) - If no CTF data was found and the write fails the user can force a write with -l [size] - The allowed lengths of a forced write are 1, 2, 4, and 8 bytes. Both of the above work with integer, pointer, and enum types (except the -l option in the dcmd that doesn't care about the type). Upstream Bugs: DLPX-48141 You can view, comment on, or merge this pull request online at: https://github.com/openzfs/openzfs/pull/544 -- Commit Summary -- * Add mdb smart write -- File Changes -- M usr/src/cmd/mdb/common/mdb/mdb_cmds.c (192) M usr/src/cmd/mdb/common/mdb/mdb_fmt.c (4) M usr/src/cmd/mdb/common/mdb/mdb_lex.l (3) M usr/src/man/man1/mdb.1 (2) -- Patch Links -- https://github.com/openzfs/openzfs/pull/544.patch https://github.com/openzfs/openzfs/pull/544.diff -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/openzfs/openzfs/pull/544 ------------------------------------------ openzfs-developer Archives: https://openzfs.topicbox.com/groups/developer/discussions/Tab9df74196897556-M3a6e2ea09de07e449b354460 Powered by Topicbox: https://topicbox.com