Bug 72355

Summary: Can't run strings(1) on a (disk) device, even if you want to
Product: Base System Reporter: Pierre Beyssac <beyssac>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: emaste
Priority: Normal    
Version: 5.3-BETA5   
Hardware: Any   
OS: Any   

Description Pierre Beyssac 2004-10-05 16:00:39 UTC
Cannot "strings" a disk device even if you want to:

	# strings /dev/da2s1
	strings: Warning: '/dev/da2s1' is not an ordinary file
	#

Two misfeatures in one:
1. the warning is bogus, it is actually treated as an error: strings
   exits instead of going on with its job as would seem logical.
2. there is no documented way to override this behaviour.

Fix: 

Unknown.
Comment 1 David Schultz freebsd_committer freebsd_triage 2004-10-06 22:08:12 UTC
> 	# strings /dev/da2s1
> 	strings: Warning: '/dev/da2s1' is not an ordinary file

I can't speak for why strings does this or whether it should be
considered a bug or not, but a way to override it is
'cat /dev/da2s1 | strings'.
Comment 2 beyssac 2004-10-06 23:31:18 UTC
On Wed, Oct 06, 2004 at 05:08:12PM -0400, David Schultz wrote:
> I can't speak for why strings does this or whether it should be
> considered a bug or not, but a way to override it is
> 'cat /dev/da2s1 | strings'.

Thanks! Since I sent the PR I have also found "strings < /dev/da2s1"
which saves a cat; but still...
-- 
Pierre Beyssac						pb@enst.fr
Comment 3 Ryan Sommers 2004-10-08 05:28:56 UTC
According to POSIX: "The /strings/ utility shall look for printable 
strings in regular files and shall write those strings to standard output."

 From the looks of it strings isn't supposed to work on devices. Depends 
on how literally you take "regular files" to mean.

-- 
Ryan Sommers
ryans@gamersimpact.com
Comment 4 beyssac 2004-10-08 09:14:36 UTC
On Thu, Oct 07, 2004 at 11:28:56PM -0500, Ryan Sommers wrote:
> According to POSIX: "The /strings/ utility shall look for printable 
> strings in regular files and shall write those strings to standard output."

Well, sorry but I don't quite see in what respect this precludes a
POSIX-compliant strings from working on devices too (just as FreeBSD
4.10 strings does).
-- 
Pierre Beyssac						pb@enst.fr
Comment 5 Ed Maste freebsd_committer freebsd_triage 2017-11-21 14:57:32 UTC
This is fixed with the migration to ELF Tool Chain strings, as of FreeBSD 11.0.

Testing with a memory disk:

# newfs_msdos /dev/md0
newfs_msdos: cannot get number of sectors per track: Operation not supported
newfs_msdos: cannot get number of heads: Operation not supported
/dev/md0: 2003 sectors in 2003 FAT12 clusters (512 bytes/cluster)
BytesPerSec=512 SecPerClust=1 ResSectors=1 FATs=2 RootDirEnts=512 Sectors=2048 Media=0xf0 FATsecs=6 SecPerTrack=63 Heads=1 HiddenSecs=0
# strings /dev/md0
BSD4.4  
NO NAME    FAT12   
Non-system disk
Press any key to reboot
#