By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a

"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

P: n/a
> 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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.