LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-17-2015, 10:07 AM   #1
Garrett85
Member
 
Registered: Jan 2011
Posts: 332

Rep: Reputation: 6
diif -qr input/output error


garrett@mint-desktop ~ $ diff -qr ~/Music/ /media/garrett/6BF6-AC8A
Only in /home/garrett/Music/Coldplay: A Rush of Blood to the Head
diff: /media/garrett/6BF6-AC8A/Collective Soul/Afterwords/02. What I Can Give You.flac: Input/output error

I got the above while trying to test the difference between my music library and my SDcard. What I'd like to know is did diff stop running after it hit the Input/output error or did it finish the complete check and then output the error message?
 
Old 10-17-2015, 11:08 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
I would say diff is not really usable for binary files, it tries to compare files line by line.
You can check the man page of diff: Exit status is 0 if inputs are the same, 1 if different, 2 if trouble. I assume you got 2 and that means you cannot rely on the output after that (but I'm not really sure, I found no information)
 
Old 10-18-2015, 06:04 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Use cmp for comparing binaries.
 
Old 10-18-2015, 08:18 AM   #4
Garrett85
Member
 
Registered: Jan 2011
Posts: 332

Original Poster
Rep: Reputation: 6
I need to step down recursively through all the directories to compare my music file, I don't see a recursive option for cmp.
 
Old 10-18-2015, 11:45 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
that will not make diff work for you. There is a tool dupfinder probably that would be a better option for you.
http://sourceforge.net/projects/doub...atest/download
 
Old 10-18-2015, 01:09 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
You can run diff with the "-q" (--brief) option, which will simply report whether files differ. Then there should be no problem with binary files.

The problem with the I/O error will still be there because that file (presumably on the SD card) is simply unreadable. There should be some error message in the system logs with more details.
 
Old 10-18-2015, 06:11 PM   #7
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Garrett85 View Post
I need to step down recursively through all the directories to compare my music file, I don't see a recursive option for cmp.
That's what shell scripts are for. In a script, you would also have control over the recursion and ensure that the program doesn't stop when it encounters a file with errors.

On the other hand, it seems that diff -qr is a viable solution, and pan64's remark about the exit code is the answer to your question.
 
Old 10-18-2015, 08:13 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You could try generating checksums eg MD5, sha1, whatever, for each file and compare those?
 
Old 10-18-2015, 10:09 PM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
It depends on what you are trying to do. If you have two directory trees that should be identical with matching content in the files, then "diff -rq" is the simplest tool for the job. If you're looking for files with identical content that are located in different places in the directory tree and perhaps with different names, then matching MD5 sums or a tool like dupfinder is what you need. It seems to me that the OP was doing the former.
 
Old 10-19-2015, 10:32 AM   #10
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
this may yeild an answer

$ strace diff -qr ~/Music/ /media/garrett/6BF6-AC8A

> I got the above while trying to test the difference between my music library and my SDcard. What I'd like to know is did diff stop running after it hit the Input/output error or did it finish the complete check and then output the error message?

consider running LFS. you can look at the source to know when the VERY SAME text error message is printed and even modify it

C programming language binaries. they have ASM startup code that runs after linux loader copies binary into memory (it fills in some offset pointers and options too)

the startup code initiates interrupts and opens some stream files (stdio) /dev/stdout, /dev/stderr

you saw the message but if it was in a stream it may have been printed at ANY TIME: so you are right! you do not know just by seeing the terminal text when the message printed: it may have been stderr or stdout. stderr does not "sync" when stdout does they are asynchronous. you dont even know (unless in the C code fflush(stderr) is used) that while processing some interrupt if stdout file stream was not held before / during / after an io error.

they are file streams (not direct io) and are processed "as soon as is convenient", thus they are very efficient and the programmer does not have to do a thing but use printf("hello world\n") to get excellent unix io. but what unix users/programs do have to keep in mind is "race conditions". it's a world of asynchronous times. if you ever want to know times "in different worlds" you have to have a "lock", a spin lock, you have to have a hard reference and check against it, to avoid "race conditions".

here the race condition is your question: did the chicken or egg print first?
 
Old 10-20-2015, 08:10 PM   #11
Garrett85
Member
 
Registered: Jan 2011
Posts: 332

Original Poster
Rep: Reputation: 6
berndbausch I'm confused. First you says that diff -qr is a viable option and then you say that that pan64's answer is good and he said "that will not make diff work for you". Also, diff -qr is exactly the option I tried and it's the very fist thread on this discussion.
 
Old 10-20-2015, 09:10 PM   #12
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Garrett85 View Post
berndbausch I'm confused. First you says that diff -qr is a viable option and then you say that that pan64's answer is good and he said "that will not make diff work for you". Also, diff -qr is exactly the option I tried and it's the very fist thread on this discussion.
I said pan64's answer about the exit code: "You can check the man page of diff: Exit status is 0 if inputs are the same, 1 if different, 2 if trouble. I assume you got 2 and that means you cannot rely on the output after that (but I'm not really sure, I found no information)"
 
Old 10-21-2015, 07:50 AM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
To be sure, you would need to use strace (as debguy suggested) or examine the source, but I would say it's 90% likely that diff simply stopped when it encountered the I/O error and did not examine other files.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] stty: standard input: Input/output error [bash] DoME69 Programming 7 05-22-2015 12:14 AM
Error fsyncing/closing/dev/sda: Input/output error Petalocsta Linux - Laptop and Netbook 2 11-07-2011 05:40 PM
aplay: pcm_write:1029: write error: Input/output error mimithebrain Linux - Software 2 12-04-2007 11:51 AM
RPM iinstallation [error: failed to stat /mnt/windows: Input/output error] Ameii83 Linux - Software 1 04-09-2007 07:05 AM
cp - error reading /mnt/cdrom/mpegav/avseq01.dat input/output error manishsingh4u Linux - General 2 10-17-2005 05:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration