473,545 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can python 'read disk sectors' like/via linux:dd ?

OP wrote:
}in order to justify learning another language I'd first need to be
}convinced that python could easily do the following:-
}
}ReadSectors2Bu fr(hdx, StartSectr, SectrCnt, Bufr); <-- like linux:dd
}PrintDecOf4Byt es(Offset, Bufr); <-- and also 1 and 2 byte values
}OverWriteBufr( Offset, Bufr, Byte);
}WriteBufr2Sect ors ..... <-- like linux: dd
}
}I guess one would normally use bash, but I'd rather invest effort
}in python if it can do this.
}
}Thanks for any info.
-----------

Pascal Bourguignon wrote:
In unix, disks are files like any other file.
So if your programming language allows you to
read and write files, it allows you to read and
write disks.
Just write the equivalent of:
int fd=open("/dev/hda",O_RDWR,0) ;
if(0<==fd){
check_errors(ls eek(fd,SECT_SIZ E*sect_num,SEEK _SET));
check_errors(re ad(fd,buffer,SE CT_SIZE));
modify(buffer);
check_errors(ls eek(fd,SECT_SIZ E*sect_num,SEEK _SET));
check_errors(wr ite(fd,buffer,S ECT_SIZE)); close(fd); }
and be sure to have the access rights on /dev/hda (and to know
what you're doing!).

Tauno Voipio wrote: Are you attempting to create a boot block virus?


Firstly, if you asked me advice on where to buy some goats-milk,
I'd answer in the context of where YOU stand now [especially
since you told me], NOT form where I'm standing.

For several reasons I need many partitions on my IDEs.
The one lost the chain of logical partitions at hdx26.
It's not linux, but that's not important.
The most convenient tool for ME [at my present status] to
read/write blocks is linux: dd; and to see/edit is linux:mc.
This involves a lot of tiring manual work.
I previously read of a contributor who automated the steps
of linux:fdisk [iterating through size guesses] inside of a bash
script, to recover his lost [last] partition.
I'm not keen on investing time to become more fluent in Bash,
which could drive dd.
I have other reasons to invest time in Python.
If Pyton could 'drive' dd, I would try it.

My normal OS is oberon S3, which can do better than the
C-code above, but I want to work at the highest level.

Understand ?

Thanks,

== Chris Glur.

Nov 9 '05 #1
1 4527
ne**@absamail.c o.za wrote:
OP wrote:
}in order to justify learning another language I'd first need to be
}convinced that python could easily do the following:-
}
}ReadSectors2Bu fr(hdx, StartSectr, SectrCnt, Bufr); <-- like linux:dd
}PrintDecOf4Byt es(Offset, Bufr); <-- and also 1 and 2 byte values
}OverWriteBufr( Offset, Bufr, Byte);
}WriteBufr2Sect ors ..... <-- like linux: dd
}
}I guess one would normally use bash, but I'd rather invest effort
}in python if it can do this.
}
}Thanks for any info.
-----------

Pascal Bourguignon wrote:
In unix, disks are files like any other file.
So if your programming language allows you to
read and write files, it allows you to read and
write disks.
Just write the equivalent of:
int fd=open("/dev/hda",O_RDWR,0) ;
if(0<==fd){
check_errors(ls eek(fd,SECT_SIZ E*sect_num,SEEK _SET));
check_errors(re ad(fd,buffer,SE CT_SIZE));
modify(buffer);
check_errors(ls eek(fd,SECT_SIZ E*sect_num,SEEK _SET));
check_errors(wr ite(fd,buffer,S ECT_SIZE)); close(fd); }
and be sure to have the access rights on /dev/hda (and to know
what you're doing!).

Tauno Voipio wrote:
Are you attempting to create a boot block virus?

Firstly, if you asked me advice on where to buy some goats-milk,
I'd answer in the context of where YOU stand now [especially
since you told me], NOT form where I'm standing.

For several reasons I need many partitions on my IDEs.
The one lost the chain of logical partitions at hdx26.
It's not linux, but that's not important.
The most convenient tool for ME [at my present status] to
read/write blocks is linux: dd; and to see/edit is linux:mc.
This involves a lot of tiring manual work.
I previously read of a contributor who automated the steps
of linux:fdisk [iterating through size guesses] inside of a bash
script, to recover his lost [last] partition.
I'm not keen on investing time to become more fluent in Bash,
which could drive dd.
I have other reasons to invest time in Python.
If Pyton could 'drive' dd, I would try it.

My normal OS is oberon S3, which can do better than the
C-code above, but I want to work at the highest level.

Understand ?


Yes, I do.

But, there is a good tool to repair partition tables.
Google for 'gpart'.

--

Tauno Voipio
tauno voipio (at) iki fi
Nov 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
11768
by: sf | last post by:
Just started thinking about learning python. Is there any place where I can get some free examples, especially for following kind of problem ( it must be trivial for those using python) I have files A, and B each containing say 100,000 lines (each line=one string without any space) I want to do
2
5275
by: AES/newspost | last post by:
In a markup like <dd> <br> some other stuff <br> </dd> the first break seems to add a blank line before the other stuff, but the second doesn't add a blank line after the other stuff. The same seems to hold for <dt>. Is this a universal rule, or does it apply to many other HTML constructs? Is there some logical reason for it?
3
466
by: news | last post by:
Hi, in order to justify learning another language I'd first need to be convinced that python could easily do the following:- ReadSectors2Bufr(hdx, StartSectr, SectrCnt, Bufr); <-- like linux: dd PrintDecOf4Bytes(Offset, Bufr); <-- and also 1 and 2 byte values OverWriteBufr(Offset, Bufr, Byte); WriteBufr2Sectors ..... <-- like linux: dd ...
1
1163
by: Kevin | last post by:
Hi All I am really having problems with the DateTime class. Please can someone tell me how to pass a simple string like "26/05/2003" or "2003/05/26" etc into a DateTime class. When I read the help, I am seeing things Like Cultureinfo classes, IFormatProvider, Calendar Classes, I don't know whats what, please can someone explain all this...
3
9516
by: CyberLotus | last post by:
Hi, I wish to validate the date a user has entered against the format dd-mmm-yyyy using the CompareValidator, but it does not work. Does anybody have a simple solution please? Many thanks in advance.
16
12670
by: Filips Benoit | last post by:
Dear all, I have a datefield that sometimes should store hours and minutes too ans use following format and inputmask. dd/mm/yyyy hh\:nn 09/09/0000\ 99:99;0;* Typing date, hour and minutes is OK.
2
2554
by: Arno R | last post by:
Hi all, In a converted app (converted from A97 to A2k) I just noticed that the format of a certain datefield is not working properly. This is with a control (datefield) on a bound form. When I use a format property like dd-mm-yyyy the date is shown as 27-01-2006 as expected BUT when using a format property of dd-mm-yy the date...
3
52424
by: yogi | last post by:
Hi, I am working on a database that has a variable with timestamp values. I wanted to convert the variable from timestamp to yyyy-mm-dd format. Thanks in advance Yogi
0
7502
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7434
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7692
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.