Thank you for your prompt and thoughtful feedback
The pre-write check is safe and does not affect the write even if probing fails. It merely warns and prompts for confirmation when detecting that the device appears mounted, contains a partition table, or is an LVM physical volume. If the user confirms, dd proceeds unaltered. Probing failures are silently ignored—detection is purely advisory. The check adds a safety net against accidental data loss without altering dd's core behaviour. I hope this clarifies the intent. thanks, Jianing Weng On 08/09/2026 19:19, Padraig writes: >Again I think the warning about existing structures will cause more issues than it solves. > >Also please keep all responses on the list. > >thanks, >Padraig > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >On 07/09/2026 06:35, ii wrote: > Dear Padraig, > > Thank you for your prompt and thoughtful feedback on my initial patch. > In particular, I appreciate the point that checking whether to overwrite > existing file system structures is of limited utility , and that adding a > dependency on libblkid is not ideal. > > I have revised the patch substantially: > > 1. > > remove the file‑system structure overwrite check entirely. > > 2. > > remove the libblkid dependency – the new implementation > > does not pull in any extra library. > 3. > retain only a best-effort check that warns the output block > device appears to be: currently mounted, LVM physical volume, > or containing an MBR or GPT partition table > > > These checks are performed by reading a few initial sectors directly > and parsing the on‑disk signatures. The detection is purely advisory: > any failure during probing is silently ignored and treated as > "nothing detected", so |dd| will never fail or change its behaviour > because of pre-write safety check. The warning is only issued when > |dd| is run interactively, and it asks for user confirmation before proceeding. > > The patch is attached. Please let me know if you have further questions or suggestion. > > Thank you again for your time and guidance, > Jianing Weng ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > On 04/09/2026 22:54, Pádraig Brady <[email protected]> wrote: > On 04/09/2026 10:22, ii via GNU coreutils Bug Reports wrote: >> if dd is used to write block device, would destroy in-use devices, or LVM, &nbsp;partition tables on devices. &nbsp; >> Before opening the output, probe with libblkid and warn if content is recognized, prompting for confirmation. > > Checking whether a device is mounted does seem potentially useful. > > Checking whether to overwrite existing file system structures seems less useful, > as that would be a very common scenario. Also that functionality adds the > libblkid dependency which isn't ideal. > >thanks, >Padraig ii [email protected]
