 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
shakeel-ur-rehman Guest
|
Posted: Sat Jan 24, 2004 4:18 am Post subject: sector , file and partition reading in C++ |
|
|
I am wrtiting programm in C++ to read/take complete image of the
partiton. can any one let me know the internet resources and web
sites having tutorials relating to this and tell any sequence of how
to writing code in order to catch and complete directory structure of
a partition with out using windows API i mean only assembly and C or
C++.
Shakeel
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Sat Jan 24, 2004 5:35 am Post subject: Re: sector , file and partition reading in C++ |
|
|
"shakeel-ur-rehman" <shakeelj2k (AT) yahoo (DOT) com> wrote...
| Quote: | I am wrtiting programm in C++ to read/take complete image of the
partiton. can any one let me know the internet resources and web
sites having tutorials relating to this and tell any sequence of how
to writing code in order to catch and complete directory structure of
a partition with out using windows API i mean only assembly and C or
C++.
|
Neither C nor C++ has any means to control/communicate with a device
(in your case a hard drive). Whatever mechanisms are available for
that are hardware- and platform-specific and as such are OT here.
Please ask in the newsgroup that deals with Assembly or with your OS
(even though you don't want to use their API, you may have to).
V
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
Posted: Sat Jan 24, 2004 5:53 am Post subject: Re: sector , file and partition reading in C++ |
|
|
Victor Bazarov wrote:
| Quote: | Neither C nor C++ has any means
to control/communicate with a device (in your case a hard drive).
|
Nonsense!
Most hardware drivers are written in C.
| Quote: | Whatever mechanisms are available for that
are hardware- and platform-specific and as such are OT here.
|
That is correct.
| Quote: | Please ask in the newsgroup that deals with [Assembler]
|
Please don't. This would be off-topic there as well.
| Quote: | or with your [Operating System]
(even though you don't want to use their API, you may have to).
|
Correct.
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Sat Jan 24, 2004 11:23 am Post subject: Re: sector , file and partition reading in C++ |
|
|
E. Robert Tisdale wrote:
| Quote: | Victor Bazarov wrote:
Neither C nor C++ has any means
to control/communicate with a device (in your case a hard drive).
Nonsense!
Most hardware drivers are written in C.
|
If people write about "C" or "C++" here, they mean those languages as
defined by the ISO/IEC standards, and those really don't have any way
to control hardware. You need system specific extensions that are not
part of the language itself.
|
|
| Back to top |
|
 |
dude Guest
|
Posted: Sat Jan 24, 2004 12:34 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
"Rolf Magnus" <ramagnus (AT) t-online (DOT) de> wrote
| Quote: | E. Robert Tisdale wrote:
Victor Bazarov wrote:
Neither C nor C++ has any means
to control/communicate with a device (in your case a hard drive).
Nonsense!
Most hardware drivers are written in C.
If people write about "C" or "C++" here, they mean those languages as
defined by the ISO/IEC standards, and those really don't have any way
to control hardware. You need system specific extensions that are not
part of the language itself.
|
So C and C++ don't have any way to communicate directly w/hardware? You can
write an OS in almost all C... So if you booted to DOS or something like
that you would HAVE to use the DOS interrupts to read/write to the hard
drive? Wouldn't that be slow for programs like Norton Ghost and the like???
I know this is off topic but Robert said it would be off topic in an
Assembler group as well. If C can't do it Assembler certainly could.
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Sat Jan 24, 2004 2:31 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
dude wrote:
| Quote: |
"Rolf Magnus" <ramagnus (AT) t-online (DOT) de> wrote in message
news:butl1f$fae$05$1 (AT) news (DOT) t-online.com...
E. Robert Tisdale wrote:
Victor Bazarov wrote:
Neither C nor C++ has any means
to control/communicate with a device (in your case a hard drive).
Nonsense!
Most hardware drivers are written in C.
If people write about "C" or "C++" here, they mean those languages as
defined by the ISO/IEC standards, and those really don't have any way
to control hardware. You need system specific extensions that are not
part of the language itself.
So C and C++ don't have any way to communicate directly w/hardware?
|
Right.
| Quote: | You can write an OS in almost all C...
|
....but only with system specific extensions that are not part of the
language itself (though they can often be used with that language).
| Quote: | So if you booted to DOS or something like that you would HAVE to use
the DOS interrupts to read/write to the hard drive?
|
You have to use the standard C and C++ functions to open, read and write
files. Whether those files are at all on a hard drive depends on the
system.
However, that doesn't mean that you can't use C or C++ to do low-level
work like raw disk sector reading/writing or directly access hardware
like you need to do in a driver. If you're programming for a specific
system, you can of course take advantage of that and use whatever
possibilities that system offers you, which is usually much more. It's
just that the languages have no built-in facilities for it, since
operating systems and hardware devices are just too different from each
other and evolving too fast, so such facilities would always be
non-portable.
| Quote: | Wouldn't that be slow for programs like Norton Ghost and the like???
|
Are those still running under DOS? Note that many modern operating
systems don't even give you direct access to hardware, since that would
endanger system integrity.
| Quote: | I know this is off topic but Robert said it would be off topic in an
Assembler group as well. If C can't do it Assembler certainly could.
|
|
|
| Back to top |
|
 |
Alexander Terekhov Guest
|
Posted: Sat Jan 24, 2004 6:04 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
Rolf Magnus wrote:
[...]
| Quote: | If people write about "C" or "C++" here, they mean those languages as
defined by the ISO/IEC standards, and those really don't have any way
to control hardware. You need system specific extensions that are not
part of the language itself.
So C and C++ don't have any way to communicate directly w/hardware?
Right.
|
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/PDTR18015.pdf
(see "The <hardware> Interface for C++")
regards,
alexander.
|
|
| Back to top |
|
 |
Thomas Matthews Guest
|
Posted: Sun Jan 25, 2004 8:50 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
Rolf Magnus wrote:
| Quote: | E. Robert Tisdale wrote:
Victor Bazarov wrote:
Neither C nor C++ has any means
to control/communicate with a device (in your case a hard drive).
Nonsense!
Most hardware drivers are written in C.
If people write about "C" or "C++" here, they mean those languages as
defined by the ISO/IEC standards, and those really don't have any way
to control hardware. You need system specific extensions that are not
part of the language itself.
|
If the hardware is memory mapped, then you don't need any system
specific extensions to the language, whether it be C or C++.
For example, if a UART receive register is located at 0x4000 and
it is CHAR_BITS wide, then one could read a character by:
volatile char * const UART_RECIEVE_REG = 0x4000;
char read_from_uart(void)
{
return *UART_RECEIVE_REG;
}
In the above example, it is valid C++. The location is volatile
because its value is changed by the hardware without the program's
control. The pointer is constant because the UART's receive
register is mapped to a fixed address in memory.
If the hardware devices are mapped to a different space, such
as ports, then some kind of language extension is required since
the C++ language does not have facilities for ports.
If an application, whether it be embbeded or not, wants to use
an operating system function for accessing hardware, then those
functions are not part of the _standard_ language. The functions
would be platform specific.
Since I have used specific values for addresses, the function
is not portable; but it is still compliant.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Mon Jan 26, 2004 12:12 am Post subject: Re: sector , file and partition reading in C++ |
|
|
Thomas Matthews wrote:
| Quote: | Neither C nor C++ has any means
to control/communicate with a device (in your case a hard drive).
Nonsense!
Most hardware drivers are written in C.
If people write about "C" or "C++" here, they mean those languages as
defined by the ISO/IEC standards, and those really don't have any way
to control hardware. You need system specific extensions that are not
part of the language itself.
If the hardware is memory mapped, then you don't need any system
specific extensions to the language, whether it be C or C++.
|
Yes, you do. That memory mapping already _is_ the system specific
extension.
| Quote: | For example, if a UART receive register is located at 0x4000 and
it is CHAR_BITS wide, then one could read a character by:
volatile char * const UART_RECIEVE_REG = 0x4000;
|
The result of an integer-to-pointer conversion is implementation
defined. That means that the C++ standard doesn't actually state what
the value of the resulting pointer will be if you assign 0x4000 to it,
IOW it's system specific, and of course it's also system specific
whether there is any special hardware at that address.
IMHO, those things all fall into the category of system specific
extensions.
|
|
| Back to top |
|
 |
Fred H Guest
|
Posted: Mon Jan 26, 2004 10:53 am Post subject: Re: sector , file and partition reading in C++ |
|
|
I'm faced with much the same problem as the OP.
Alexander Terekhov wrote:
I copied the following code from the above document:
#include <hardware>
#include "driv_defs.h"
register_access<PortA1_T, Platform> devStatus;
register_access<PortA2_T, Platform> devOut;
const uint8_t statusBusy = 0x4;
uint8_t ch = ' ';
// Wait until controller is no longer busy:
while (devStatus & statusBusy) ; // do nothing
// Write some value to controller:
devOut = ch;
I get the big picture, and this is just plain beautifull.
But where can I get the <hardware> interface? And say that
I'm trying to communicate with a hard disk drive on an
Intel PC, where can I get the "drive_defs.h" for this
platform?
Where does one find information about this stuff...?
And does anyone know how (or where to find out how) one
plugs into say the Linux and Windows core, in order to
actually get the permission to do such low level calls
to a device? (Ok, slightly OT for the group, but hey,
the whole point is that I don't know where else to ask )
--
Fred H, paranoid norwegian hardware developer :-)
void FredH::Contact() {
TextToSpeach.say("frode at age dee dee dot en oh");
}
|
|
| Back to top |
|
 |
Karl Heinz Buchegger Guest
|
Posted: Mon Jan 26, 2004 12:40 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
Fred H wrote:
| Quote: |
Where does one find information about this stuff...?
And does anyone know how (or where to find out how) one
plugs into say the Linux and Windows core, in order to
actually get the permission to do such low level calls
to a device? (Ok, slightly OT for the group, but hey,
the whole point is that I don't know where else to ask )
|
Slightly off-topic?
Completely off-topic.
What about asking in a newsgroup which at least deals with
your operating system.
--
Karl Heinz Buchegger
[email]kbuchegg (AT) gascad (DOT) at[/email]
|
|
| Back to top |
|
 |
Fred H Guest
|
Posted: Mon Jan 26, 2004 2:17 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
Thank you for your timely reply... :
| Quote: | Slightly off-topic?
Completely off-topic.
|
But still in the context of the thread.
| Quote: | What about asking in a newsgroup which at least deals with
your operating system.
|
Sure, but why go ballistic just because I ask one OT question
in the context of the thread, when there's obviously people
present that might have an answer...?
|
|
| Back to top |
|
 |
Karl Heinz Buchegger Guest
|
Posted: Mon Jan 26, 2004 2:36 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
Fred H wrote:
| Quote: |
Thank you for your timely reply... :
Slightly off-topic?
Completely off-topic.
But still in the context of the thread.
|
How come?
Just because you program in C++, it doesn't mean that
all problems you encounter while doing your program
are automatically C++ problems and will be discussed in
comp.lang.c++
| Quote: |
What about asking in a newsgroup which at least deals with
your operating system.
Sure, but why go ballistic just because I ask one OT question
in the context of the thread, when there's obviously people
present that might have an answer...?
|
Because those people know the rules of the group and ...
mark your post as off topic and don't answer.
Those very same people might provide a wonderful answer
in one of the groups where your question is on topic.
--
Karl Heinz Buchegger
[email]kbuchegg (AT) gascad (DOT) at[/email]
|
|
| Back to top |
|
 |
Fred H Guest
|
Posted: Mon Jan 26, 2004 3:19 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
| Quote: | Those very same people might provide a wonderful answer
in one of the groups where your question is on topic.
|
....which is why I also asked for -where- I might find
more information, since I, for one, don't know all
usefull usenet groups off the top of my head.
But this OT discussion is now getting REALLY OT,
so I'll try and find some answers elswhere.
....he bitterly groaned ;-)
--
Fred H
void FredH::Contact() {
TextToSpeach.say("frode at age dee dee dot en oh");
}
|
|
| Back to top |
|
 |
osmium Guest
|
Posted: Mon Jan 26, 2004 3:52 pm Post subject: Re: sector , file and partition reading in C++ |
|
|
Fred H writes:
| Quote: | Those very same people might provide a wonderful answer
in one of the groups where your question is on topic.
...which is why I also asked for -where- I might find
more information, since I, for one, don't know all
usefull usenet groups off the top of my head.
But this OT discussion is now getting REALLY OT,
so I'll try and find some answers elswhere.
...he bitterly groaned
|
Sorry for the blank post.
You have a common problem. What I would do is go to google advanced groups
and search for likely groups. Require <windows api> and at least one of
<sector file partition> Then look at the *groups* returned, not so much as
the message. You may (depending on what browser you have) be able to
examine the group for being dormant without leaving the environment you have
set up. I have just done this for your question and come up with
comp.os.ms-windows.programmer.win32 as a likely candidate.
Many of us think of Petrol as being *the* Windows API, but in fact it is
only the GUI part of the API. If I were in a hurry and couldn't find a lead
in a few minutes I would be off to the book store to look at books on the
Windows API. But of course this only works if you are in fairly sizable
city.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|