Hi all, my program does the following:
mbr = fopen(fullpath, "r");
if (!mbr) {
fprintf(stderr, "VxVM ERROR V-5-3-000: Can't open device %s
\n",
fullpath);
return 0;
}
count = fread(buffer, 1, 512, mbr);
if (count < 512) {
return and print error
}
the problem is when a disk has been pulled from the system, my call to fread() on linux never returns, it just hangs (got this from gdb debugger).
Any ideas???
4 1902
Hi all, my program does the following:
mbr = fopen(fullpath, "r");
if (!mbr) {
fprintf(stderr, "VxVM ERROR V-5-3-000: Can't open device %s
\n",
fullpath);
return 0;
}
count = fread(buffer, 1, 512, mbr);
if (count < 512) {
return and print error
}
the problem is when a disk has been pulled from the system, my call to fread() on linux never returns, it just hangs (got this from gdb debugger).
Any ideas???
-
mbr = fopen(fullpath, "r");
-
if (!mbr) {
-
fprintf(stderr, "VxVM ERROR V-5-3-000: Can't open device %s
-
\n",
-
fullpath);
-
return 0;
-
}
-
-
count = fread(buffer, 1, 512, mbr);
-
if (count < 512) {
-
return and print error
-
}
-
Remember the code brackets
Why don't you try:
why mbr.read() as opposed to
read(mbr, buf, sizeof(buf)) ?
will read() solve the problem of hanging? Any idea why?
tried using read() instead. Got the same result....hang
fread() is part of the C file system which dates to 1972. Back then you didn't have removable disks. fread() expects the disk to be ready and waits until it is.
Being able to pop a disk in or out (Windows Plug-and-Play) required all new code for the file system so that the program could continue if the disk were removed unexpectedly.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alain Lafon |
last post by:
Helas,
I got something that should be a minor problem, but anyhow it isn't to me
right now.
A little code fragment:
fread(&file_qn, x, 1, fp_q);
The corresponding text file looks like...
|
by: Patrice Kadionik |
last post by:
Hi all,
I want to make a brief comparison between read() and fread() (under a
Linux OS).
1. Family read and Co: open, close, read, write, ioctl...
2. Family fread and Co: fopen, fclose,...
|
by: John |
last post by:
I have a file open using fopen and am reaing using fread.
Does this mean that the OS (linux) already buffers this
file? What is the buffer size? Can I change it?
Thanks,
--j
|
by: joel.washburn |
last post by:
I'm looking for some information on why fread calls max out CPU usage
on SSL connections in windows. I've tried upgrading PHP (now at 5.1.2)
and OpenSSL (now 9.8) but cannot stop fread() from...
|
by: M. Åhman |
last post by:
I'm reading "C: A Reference Manual" but still can't understand a
very basic thing: is there any functional difference between
fgetc/fputc and fread/fwrite (when reading/writing one unsigned
char)?...
|
by: 010 010 |
last post by:
I found this very odd and maybe someone can explain it to me.
I was using fread to scan through a binary file and pull bytes out. In
the middle of a while loop, for no reason that i could...
|
by: David Mathog |
last post by:
When reading a binary input stream with fread() one can
read N bytes in two ways :
count=fread(buffer,1,N,fin); /* N bytes at a time */
or
count=fread(buffer,N,1,fin); /* 1 buffer at a...
|
by: howa |
last post by:
are there any advantage in replacing all fread() operations with
file_get_contents() ?
i.e.
file_get_contents("/usr/local/something.txt")
VS
$filename = "/usr/local/something.txt";
|
by: ericunfuk |
last post by:
If fseek() always clears EOF, is there a way for me to fread() from an
offset of a file and still be able to detect EOF?i.e. withouting using
fseek(). I also need to seek to an offset in the file...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |