473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Is it possible to detect if files on a drive were changed without scanning the drive?

It is maybe not a pure Python question, but I think
it is the right newsgroup to ask for help, anyway.

After connecting a drive to the system (via USB
or IDE) I would like to be able to see within seconds
if there were changes in the file system of that drive
since last check (250 GB drive with about four million
files on it).

How to accomplish this? (best if providing
directly a Python receipe for it :-)
Do available file systems have something like
archive attribute assigned to the root directory
of the drive?
I suppose not. Am I right?

I ask this question having Microsoft Windows 2000
and Windows proprietary NTFS file system in mind,
but I am also interested to know it about Linux or
Unix file systems.

I know, that looking for the archive attribute of the
top directories doesn't help when the change
happened to files somewhere deeper in the
hierarchy of directories.

Any hints are welcome.

Claudio
Sep 12 '05 #1
8 2112
On Mon, 12 Sep 2005, Claudio Grondi wrote:
It is maybe not a pure Python question, but I think it is the right
newsgroup to ask for help, anyway.
You might try comp.arch.storage or comp.sys.ibm.pc.hardware.storage, or a
newsgroup specific to the operating system you're working on.
After connecting a drive to the system (via USB or IDE) I would like to
be able to see within seconds if there were changes in the file system
of that drive since last check (250 GB drive with about four million
files on it).

How to accomplish this?


I don't think there's a portable way to do this. I also don't think
there's a way to do this at all on most disks. I think there might be a
way to do this using journalled filesystems, but i'm not certain, it would
definitely involve fiddling with low-level filesystem APIs (or even
on-disk structures), and, UIVMM, these are a minority of disks anyway.

Sorry i couldn't be more helpful!

tom

--
The revolution will not be televised. The revolution will be live.
Sep 12 '05 #2
Claudio Grondi wrote:
After connecting a drive to the system (via USB
or IDE) I would like to be able to see within seconds
if there were changes in the file system of that drive
since last check (250 GB drive with about four million
files on it).

How to accomplish this? (best if providing
directly a Python receipe for it :-)
Do available file systems have something like
archive attribute assigned to the root directory
of the drive?
I suppose not. Am I right?
On Linux there is the FAM (File Alteration Module) for this, as long as I
know. Maybe Python has a wrapper/binding for it.
I ask this question having Microsoft Windows 2000
and Windows proprietary NTFS file system in mind,
but I am also interested to know it about Linux or
Unix file systems.
As long as I know, on Windows there are a few specific "hooks" to perform
such a task. They are provided by the MS API for the NTFS/HPFS file
systems. I do not think Python implements anything so "low level", anyway.
Check the docu to be sure.
I know, that looking for the archive attribute of the
top directories doesn't help when the change
happened to files somewhere deeper in the
hierarchy of directories.


Right. It does not help.

Consider this: if are accessing a network file system, you can intercepts
the calls to the virtualization layer (NFS or NetBIOS). Most likely, Python
can support you in performing this task.

HTH
-----------------------------------
Alessandro Bottoni
Sep 12 '05 #3

"Alessandro Bottoni" <al****************@infinito.it> schrieb im Newsbeitrag
news:O7***************@twister1.libero.it...
Claudio Grondi wrote:
After connecting a drive to the system (via USB
or IDE) I would like to be able to see within seconds
if there were changes in the file system of that drive
since last check (250 GB drive with about four million
files on it).

How to accomplish this? (best if providing
directly a Python receipe for it :-)
Do available file systems have something like
archive attribute assigned to the root directory
of the drive?
I suppose not. Am I right?
On Linux there is the FAM (File Alteration Module) for this, as long as I
know. Maybe Python has a wrapper/binding for it.
I ask this question having Microsoft Windows 2000
and Windows proprietary NTFS file system in mind,
but I am also interested to know it about Linux or
Unix file systems.


As long as I know, on Windows there are a few specific "hooks" to perform
such a task. They are provided by the MS API for the NTFS/HPFS file
systems. I do not think Python implements anything so "low level", anyway.
Check the docu to be sure.
I know, that looking for the archive attribute of the
top directories doesn't help when the change
happened to files somewhere deeper in the
hierarchy of directories.


Right. It does not help.

Consider this: if are accessing a network file system, you can intercepts
the calls to the virtualization layer (NFS or NetBIOS). Most likely,

Python can support you in performing this task.

HTH
-----------------------------------
Alessandro Bottoni


Thank you for your response.

To be more clear I should maybe add, that I have not to do with
drives beeing altered while the system is running. The drives content
can be altered e.g. by the computer of a friend who I gave the drive
out to.
I tell it here, because it seems, that the answer is biased
towards detecting changes done to files on a drive while
running on a system able to monitor the drives activity.

Claudio
Sep 12 '05 #4
> After connecting a drive to the system (via USB
or IDE) I would like to be able to see within seconds
if there were changes in the file system of that drive
since last check (250 GB drive with about four million
files on it).


Whenever a file is modified the last modification time of the directory
containing it is also set. I'm not sure if the root directory itself
has a last modification time field but you can just store and compared
the last mod time of all subdirectories directly under the root
directory.

If you trust the clock of all machines mounting this drives is set
correctly (including time zone) you can store just a single timestamp
and compare for files or directories modified after that time.
Otherwise you will need to store and compare for any changes, not just
going forward.

Oren

Sep 12 '05 #5
On 2005-09-12, Oren Tirosh <or*********@gmail.com> wrote:
Whenever a file is modified the last modification time of the directory
containing it is also set.


Nope.

$ ls -ld --time-style=full-iso .
drwxr-xr-x 2 grante grante 4096 2005-09-12 12:38:04.749815352 -0500 ./

$ touch asdf

$ ls -ld --time-style=full-iso .
drwxr-xr-x 2 grante grante 4096 2005-09-12 12:39:35.657995208 -0500 ./

$ echo "hi" >asdf

$ ls -ld --time-style=full-iso .
drwxr-xr-x 2 grante grante 4096 2005-09-12 12:39:35.657995208 -0500 ./

$ echo "foo" >asdf

$ ls -ld --time-style=full-iso .
drwxr-xr-x 2 grante grante 4096 2005-09-12 12:39:35.657995208 -0500 ./

Notice that writing to the file did not change the modification
date of the directory contining it.

--
Grant Edwards grante Yow! - if it GLISTENS,
at gobble it!!
visi.com
Sep 12 '05 #6
hi list,
i'd like to define __repr__ in a class to return the standardrepr
a la "<__main__.A instance at 0x015B3DA0>"
plus additional information.
how would i have to do that?
how to get the standardrepr after i've defined __repr__?

sven.

Sep 12 '05 #7
sven wrote:
hi list,
i'd like to define __repr__ in a class to return the standardrepr
a la "<__main__.A instance at 0x015B3DA0>"
plus additional information.
how would i have to do that?
how to get the standardrepr after i've defined __repr__?

sven.

It's relatively easy for new-style (type-based) classes:
class C(object): ... def __repr__(self):
... return "Extra stuff then\n%s" % super(C, self).__repr__()
... i = C()
repr(i) 'Extra stuff then\n<__main__.C object at 0x4e0b6c>'


Not immediately clear how to extend that to old-style objects since they
aren't as cooperative in making their superclass as readily available.

Unless your needs are specifically for old-style classes I'd suggest
using new-style classes.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 12 '05 #8
sven wrote:
i'd like to define __repr__ in a class to return the standardrepr
a la "<__main__.A instance at 0x015B3DA0>"
plus additional information.
how would i have to do that?
how to get the standardrepr after i've defined __repr__?

object.__repr__(4)

'<int object at 0x94f7d8c>'

Gerrit.

--
Temperature in Luleå, Norrbotten, Sweden:
| Current temperature 05-09-15 19:19:58 7.8 degrees Celsius ( 46.0F) |
--
Det finns inte dåligt väder, bara dåliga kläder.
Sep 15 '05 #9

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

Similar topics

2
by: AMD | last post by:
Hi, I would like to have MySQL use a mapped network drive. I'd like to do this in case there is a failure of the mysql machine, I can just replace it with a new machine pointing to the same...
5
by: steve Sweales | last post by:
I am trying to design a windows forms application (not asp.net) in C#, and need to know if the following scenario is possible : Once my application is running I need to be able to impersonate...
1
by: Steve.Goodman | last post by:
Appologies if this has already been asked, but after scanning the web and this news group I could find no decent solution. We have a windows App that calls a webservice, using this bit of basic...
6
by: bfowlkes | last post by:
Hello, I am trying to parse two pre-formatted text files and write them to a different files formatted in a different way. The story about this is I was hired along with about 20 other people...
1
by: Steve Marshall | last post by:
Hi All, Apologies if this has come up before, but how can I set up something that will notify me when a removeable drive (like a USB drive or CompactFlash card) is inserted into its slot? ...
4
by: sajid_yusuf | last post by:
Hi I am trying to develop a Windows service in VB.NET which has timer enabled and keeps checking a folder (or group of folders) for any new file or changed files. As soon as it detects any new...
5
by: rogersw8n | last post by:
Some how, some way the account that creates folders under Temporary Internet files has been changed to a domain account for VS 2003 and VS 2005. I recently installed VS 2005. All seemed to be ok...
23
by: Rotsey | last post by:
Hi, I am writing an app that scans hard drives and logs info about every fine on the drive. The first iteration of my code used a class and a generic list to store the data and rhis took...
9
by: NvrBst | last post by:
Whats the best way to count the lines? I'm using the following code at the moment: public long GetNumberOfLines(string fileName) { int buffSize = 65536; int streamSize = 65536; long...
0
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.