Bug 258090 - sysutils/lsblk partition information shown for an SD card reader (in a dock) where there is no card
Summary: sysutils/lsblk partition information shown for an SD card reader (in a dock) ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-27 15:15 UTC by Graham Perrin
Modified: 2021-11-24 23:33 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (vermaden)


Attachments
Konsole transcript. (35.50 KB, text/plain)
2021-08-27 15:59 UTC, Graham Perrin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Graham Perrin freebsd_committer freebsd_triage 2021-08-27 15:15:10 UTC
A possible bug. 

In as few words as possible: 

1. I modified the GPT of a hard disk drive, whilst it was at da0
   – attention to a freebsd-swap partition, da0p3

2. with the hard disk drive later at da4, there appears to be 
   residual information at da0. 

----

% lsblk da0
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da0              0:194   0B freebsd-swap                                      - SWAP
% geom disk list da0
Geom name: da0
Providers:
1. Name: da0
   Mediasize: 0 (0B)
   Sectorsize: 512
   Mode: r0w0e0
   descr: Generic USB SD Reader
   ident: 058F312D81B
   rotationrate: unknown
   fwsectors: 0
   fwheads: 0

% freebsd-version -kru
14.0-CURRENT
14.0-CURRENT
14.0-CURRENT
% uname -KU
1400030 1400030
% pkg info -x lsblk
lsblk-3.6
%
Comment 1 Slawomir Wojciech Wojtczak 2021-08-27 15:27:41 UTC
Hi,

what is the output of *gpart show da0* command?

Regards.
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2021-08-27 15:59:10 UTC
Created attachment 227478 [details]
Konsole transcript.

Context: 

<https://lists.freebsd.org/archives/freebsd-current/2021-August/000468.html>

Lines 5–24 from within the attachment might help to explain the (much) later residual information. A misuse of srm(1):

----

root@mowa219-gjp4-8570p-freebsd:~ # srm -lv /dev/da0p3
Using /dev/urandom for random input.
Wipe mode is insecure (two passes [0xff/random])
Wiping /dev/da0p3 Warning: /dev/da0p3 is not a regular file, rename/unlink only!Warning: Couldn't rename /dev/da0p3 - Operation not supported
 Removed file /dev/da0p3 ... Done
root@mowa219-gjp4-8570p-freebsd:~ # wipe -nv /dev/da0p3
wipe: cannot stat `/dev/da0p3': No such file or directory
root@mowa219-gjp4-8570p-freebsd:~ # lsblk da0
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da0              0:181 466G GPT                                               - -
  da0p1          0:184 200M efi                                  msdosfs/EFISYS -
  da0p2          0:188 512K freebsd-boot                           gpt/gptboot0 -
  <FREE>         -:-   492K -                                                 - -
stat: /dev/da0p3: stat: No such file or directory
stat: /dev/da0p3: stat: No such file or directory
  da0p3        16G:freebsd-swap    - SWAP                                                
  da0p4          0:193 450G freebsd-zfs                                gpt/zfs0 <ZFS>
  da0p4.eli      0:196 450G zfs                                               - -
  <FREE>         -:-   4.0K -                                                 - -
root@mowa219-gjp4-8570p-freebsd:~ # gdisk /dev/da0
Comment 3 Graham Perrin freebsd_committer freebsd_triage 2021-08-27 15:59:53 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #1)

% gpart show da0
gpart: No such geom: da0.
% lsblk da0
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da0              0:194   0B freebsd-swap                                      - SWAP
%
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2021-08-27 16:16:04 UTC
(In reply to comment #2)

> … Context: 
> 
> <https://lists.freebsd.org/archives/freebsd-current/2021-August/000468.html>

– that's for completeness, however it might be an excess of information for this bug report. 


Would you like me to attempt to make the issue reproducible with as few steps as possible? 

The photograph at <https://www.heraldscotland.com/business_hq/15149526.technology-winstars-communicator-c2-hard-disk-dock/> might help to visualise the dock in which the hard disk drive is seated. 

I suspect that: 

* the bridge to the HDD appears as a relatively low numbered device i.e. 
  /dev/da0 only if the dock is connected when FreeBSD boots

* the bridge appears as a relatively high numbered device i.e. 
  /dev/da4 after switching the dock off, then on (a hard power switch 
  at the rear of the dock).
Comment 5 Slawomir Wojciech Wojtczak 2021-08-27 18:45:24 UTC
(In reply to Graham Perrin from comment #3)

> % gpart show da0
> gpart: No such geom: da0.
> 
> % lsblk da0
> DEVICE         MAJ:MIN SIZE TYPE                                          LABEL > MOUNT
> da0              0:194   0B freebsd-swap                                      - > SWAP


The lsblk(8) behaves properly here.

If gpart(8) is not able to show any partition schema then it must be something on entire device so lsblk(8) uses fstyp(8) to get the information what is on it.

Regards.
Comment 6 Graham Perrin freebsd_committer freebsd_triage 2021-08-27 21:42:26 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #5)

% fstyp /dev/da0
fstyp: /dev/da0: not a disk
% lsblk da0
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da0              0:194   0B freebsd-swap                                      - SWAP
%
Comment 7 Graham Perrin freebsd_committer freebsd_triage 2021-08-27 21:46:30 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #5)

> … something on entire device …

There is no storage device; it's the empty slot of an SD card reader


(In reply to Graham Perrin from comment #2)

Within the attached file (lines 616-626): 

Geom name: da0
Providers:
1. Name: da0
   Mediasize: 0 (0B)
   Sectorsize: 512
   Mode: r0w0e0
   descr: Generic USB SD Reader
   ident: 058F312D81B
   rotationrate: unknown
   fwsectors: 0
   fwheads: 0
Comment 8 Slawomir Wojciech Wojtczak 2021-08-28 08:34:54 UTC
(In reply to Graham Perrin from comment #7)

Understood.

Please check the fixed version from here:

https://github.com/vermaden/lsblk/blob/master/lsblk

Regards.
Comment 9 Graham Perrin freebsd_committer freebsd_triage 2021-08-28 12:49:36 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #8)

<https://github.com/vermaden/lsblk/commit/23023261d68c7e41640707cbd733068349703aa5> noted with thanks. 

Success: 

% /usr/local/sbin/lsblk da0
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da0              2:98    0B freebsd-swap                                      - SWAP
% pwd
/usr/home/grahamperrin/dev/lsblk
% grep "PROBABLY EMPTY CARD READER" ./lsblk
  # WHEN SIZE IS NOT AVAILABLE ITS PROBABLY EMPTY CARD READER
% ./lsblk da0
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
%
Comment 10 Slawomir Wojciech Wojtczak 2021-08-28 19:08:41 UTC
(In reply to Graham Perrin from comment #9)

Submitted to update in ports/packages:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258122
Comment 11 Slawomir Wojciech Wojtczak 2021-11-22 10:09:35 UTC
Is that still relevant or should we close that?
Comment 12 Graham Perrin freebsd_committer freebsd_triage 2021-11-24 23:33:49 UTC
(In reply to Slawomir Wojciech Wojtczak from comment #11)

If I recall correctly, this was fixed. Thanks.