473,668 Members | 2,406 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 4546
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
11780
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
5295
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 I guess one would normally use bash, but I'd rather invest effort
1
1166
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 for me, or point me in the right direction. As you've probably guessed, I am new to C#, so I'm...
3
9521
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
12684
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
2556
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 still shows as 27-01-2006 .... >:) (I hardly ever use a format like that, but on a specific...
3
52500
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
8462
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8893
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8802
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6209
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1787
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.