473,397 Members | 1,972 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,397 software developers and data experts.

need a good idea for catch files deleted

Good morning at all,
i have to implement a server,that every n-seconds (eg. 10sec) sends to
other clients,which files and directory has been deleted or modified.

i build a n-tree, for each files on harddisk there's a node into n-
tree,
this solution is not good for large hard disk..
and i can't use inotify (it's forbidden),
and only c solutions are accepted
without third party software or external calls.
the Hard disk are both ext3 and NTFS.

anyone has a good idea for build an efficient server??

thanks a lot

elgiei

May 12 '07 #1
7 2265
In article <11**********************@h2g2000hsg.googlegroups. com>,
elgiei <li*****@gmail.comwrote:
>Good morning at all,
i have to implement a server,that every n-seconds (eg. 10sec) sends to
other clients,which files and directory has been deleted or modified.
>i build a n-tree, for each files on harddisk there's a node into n-
tree,
this solution is not good for large hard disk..
and i can't use inotify (it's forbidden),
and only c solutions are accepted
without third party software or external calls.
the Hard disk are both ext3 and NTFS.
>anyone has a good idea for build an efficient server??
No solution is possible within the constraints imposed. You are only
permitted to use C (you indicate), without third party software or
external calls, but you need external calls for two or more aspects
of the requirements:

1) C does not provide any mechanism to delay any particular amount
of time. The closest you can come is to "busy-loop", doing some
unnecessary work and checking the clock time to determine if you've
waited long enough. Busy-loops are inherently inefficient.
Most OS's provide means to delay for approximate times, but using
such an OS facility would be using an external call, not permitted
by your specifications.

2) C does not provide any mechanism to examine directories; C doesn't
know *anything* about directories. Most OS's provide means to examine
directories, but using such an OS facility would be using an external
call, not permitted by your specifications.

3) Your specifications require that information be periodically "sent"
to other clients. C does not provide any mechanims to communicate with
clients, other than whatever can be accomplished with regular files.
It is possible to come up with a reasonable information dissemination
method based upon writing out information (pre-pended with the size of
the information) to a known file, but if you want to do a traditional
client/server architecture, you would have to use OS-specific facilities
which would require external calls, not permitted by your
specifications.
>i build a n-tree, for each files on harddisk there's a node into n-
tree,
this solution is not good for large hard disk..
How are you constructing your n-trees? Are you doing prefix-sharing
so that if you have figure1.eps and figure17.eps, the "figure1" portion
only gets stored once?
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
May 12 '07 #2
On 13 Mai, 00:40, elgiei <liug...@gmail.comwrote:
anyone has a good idea for build an efficient server??
Homework or real world problem ?

I'm afraid there isn't one. I used special code in my program but it
didn't work on linux reliable dnotify and on windows it always blocks
certain file operation so you can't use it either.

I came up with checking at certain times from a background thread.

May 12 '07 #3
first of all thanks for your attention,
my server already works with
pthread, socket, signal for timer
and many feature offered by includes,
for external call i mean for example all the "exec" 's
family,whithin you can use any binary file on your /bin directory
(or .exe file).

my ntree has
a lot of node, the same number of files and directories.
a node is composed by n pointer one for each son

so if my hard disk is composed only by :
/home/elgiei
/home/elgiei/file2.jpg
/home/elgiei/Desktop
/home/elgiei/Desktop/file1.jpg

my ntree is :

------/home/elgiei------------------------
--------- /--------\---------------------------
file2.jpg--------/home/elgiei/Desktop
-----------------------|-----------------------
------------------file1.jpg-------------------
(remove "-" with space)

after 60secs i rebuild a new ntree and i do a diff (ntreeNEW,ntreeOLD)
and i check the differences..

but it's not a smart solution for large data.

is there a signal Handler for catch file removed ?
anyone has a better idea????

i repeat the problem
i have to implement a server,that every n-seconds (eg. 10sec) sends to
other clients,which files and directory has been deleted or
modified in the system (not by my server)
the problem is catching the deleted or modified files,whitout an
expensive ntree snapshot.

a solution:
i can read all Hard disk and i can understand which files was created
or modified in the last 60-sec,
but i don't know about the deleted files.

thanks a lot

elgiei
On May 12, 8:29 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <1178991600.048490.304...@h2g2000hsg.googlegroups. com>,

elgiei <liug...@gmail.comwrote:
Good morning at all,
i have to implement a server,that every n-seconds (eg. 10sec) sends to
other clients,which files and directory has been deleted or modified.
i build a n-tree, for each files on harddisk there's a node into n-
tree,
this solution is not good for large hard disk..
and i can't use inotify (it's forbidden),
and only c solutions are accepted
without third party software or external calls.
the Hard disk are both ext3 and NTFS.
anyone has a good idea for build an efficient server??

No solution is possible within the constraints imposed. You are only
permitted to use C (you indicate), without third party software or
external calls, but you need external calls for two or more aspects
of the requirements:

1) C does not provide any mechanism to delay any particular amount
of time. The closest you can come is to "busy-loop", doing some
unnecessary work and checking the clock time to determine if you've
waited long enough. Busy-loops are inherently inefficient.
Most OS's provide means to delay for approximate times, but using
such an OS facility would be using an external call, not permitted
by your specifications.

2) C does not provide any mechanism to examine directories; C doesn't
know *anything* about directories. Most OS's provide means to examine
directories, but using such an OS facility would be using an external
call, not permitted by your specifications.

3) Your specifications require that information be periodically "sent"
to other clients. C does not provide any mechanims to communicate with
clients, other than whatever can be accomplished with regular files.
It is possible to come up with a reasonable information dissemination
method based upon writing out information (pre-pended with the size of
the information) to a known file, but if you want to do a traditional
client/server architecture, you would have to use OS-specific facilities
which would require external calls, not permitted by your
specifications.
i build a n-tree, for each files on harddisk there's a node into n-
tree,
this solution is not good for large hard disk..

How are you constructing your n-trees? Are you doing prefix-sharing
so that if you have figure1.eps and figure17.eps, the "figure1" portion
only gets stored once?
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers

May 12 '07 #4
In article <11**********************@l77g2000hsb.googlegroups .com>,
elgiei <li*****@gmail.comwrote:
>my server already works with
pthread, socket, signal for timer
None of those are part of standard C; those are all operating
system extensions.
>and many feature offered by includes,
for external call i mean for example all the "exec" 's
family,whithin you can use any binary file on your /bin directory
(or .exe file).
This is sounding more and more like an assignment rather than a
real-life program.

>my ntree has
a lot of node, the same number of files and directories.
a node is composed by n pointer one for each son
Okay.
>so if my hard disk is composed only by :
/home/elgiei
/home/elgiei/file2.jpg
/home/elgiei/Desktop
/home/elgiei/Desktop/file1.jpg
>my ntree is :

------/home/elgiei------------------------
--------- /--------\---------------------------
file2.jpg--------/home/elgiei/Desktop
-----------------------|-----------------------
------------------file1.jpg-------------------
(remove "-" with space)
So if there are duplicated prefixes, you store the prefix once per file?
That's less space efficient than it could be, but does make it easier
to insert or delete new nodes.

>after 60secs i rebuild a new ntree and i do a diff (ntreeNEW,ntreeOLD)
and i check the differences..
>but it's not a smart solution for large data.
It seems to me that you don't need to build a new ntree and do a
comparison. Provided you use a consistant ordering (e.g., depth-first,
sorted order), you should be able to start at the beginning and trace
the existing ntree through for each file: if you are processing a
file that is not part of the current n-tree then it is a new file,
and if the next file does not correspond to the next node threaded
along the leaves, then any nodes that were skipped in the process
were removed (or renamed.) It shouldn't be difficult for you to
add threading between the leaves.

>is there a signal Handler for catch file removed ?
As I indicated earlier, standard C doesn't know anything about
directories -- and all it knows about files is that if you
pass a complete null-terminated string to fopen() then some
file somewhere will be opened (or the open will fail.) Standard C
doesn't know anything about what those filename strings -mean-.

Thus, of course there is no signal or any other method in standard C
of detecting that a file has been removed: the existance of such
a function would require knowing something about filesystems, which
standard C does not.

There might be a mechanism in your operating system to notice such
things, but any such facility would be OS-specific, and you would
need to inquire about it in a newsgroup that deals with your
(unnamed) operating system. (I wasn't able to deduce which OS you
are writing this for; you mentioned inotify() which appears to be
Linux-specific, and you mentioned ext3 filesystems, which appear
to be Linux-specific, but you also mentioned NTFS filesystems,
which are proprietary to Microsoft Windows.
>anyone has a better idea????
What is the object of the assignment? To explore efficient use
of tree structures, or to explore how one would implement OS
facilities if those facilities were not already provided?
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
May 13 '07 #5
>elgiei <liug...@gmail.comwrote:
my server already works with
pthread, socket, signal for timer

None of those are part of standard C; those are all operating
system extensions.
ok i can use operative extensions infact in my code i used
#ifdef WIN32
and the else for linux..
so if my hard disk is composed only by :
/home/elgiei
/home/elgiei/file2.jpg
/home/elgiei/Desktop
/home/elgiei/Desktop/file1.jpg
my ntree is :
------/home/elgiei------------------------
--------- /--------\---------------------------
file2.jpg--------/home/elgiei/Desktop
-----------------------|-----------------------
------------------file1.jpg-------------------
(remove "-" with space)

So if there are duplicated prefixes, you store the prefix once per file?
That's less space efficient than it could be, but does make it easier
to insert or delete new nodes.
i don't know if i really understand the prefixes
in each file i already stores path/file
i don't write in that picture for space's problem.

/home/elgiei/file2.jpg--------/home/elgiei/Desktop
---------------------------------------------|-------------------
-----------------------------/home/elgiei/file1.jpg--------

and really each node has a md5 (message digest) value
it's the sum of the md5 of his son
so if nothing is changed i don't need to compare both tree, so i
compare only the modified branch
(if someone don't understand this part can asks but it it's not useful
for the solution of the problem)
That's less space efficient (really less space efficient) but it's
faster (really faster)

after 60secs i rebuild a new ntree and i do a diff (ntreeNEW,ntreeOLD)
and i check the differences..
but it's not a smart solution for large data.

It seems to me that you don't need to build a new ntree and do a
comparison. Provided you use a consistant ordering (e.g., depth-first,
sorted order), you should be able to start at the beginning and trace
the existing ntree through for each file: if you are processing a
file that is not part of the current n-tree then it is a new file,
and if the next file does not correspond to the next node threaded
along the leaves, then any nodes that were skipped in the process
were removed (or renamed.) It shouldn't be difficult for you to
add threading between the leaves.
yes it's a good solution,
but i build my new ntree becouse comparison is faster,
and after 60-sec it becomes the old ntree i have to build a new ntree
for comparison.

>
is there a signal Handler for catch file removed ?

As I indicated earlier, standard C doesn't know anything about
directories -- and all it knows about files is that if you
pass a complete null-terminated string to fopen() then some
file somewhere will be opened (or the open will fail.) Standard C
doesn't know anything about what those filename strings -mean-.

Thus, of course there is no signal or any other method in standard C
of detecting that a file has been removed: the existance of such
a function would require knowing something about filesystems, which
standard C does not.
There might be a mechanism in your operating system to notice such
things, but any such facility would be OS-specific, and you would
need to inquire about it in a newsgroup that deals with your
(unnamed) operating system. (I wasn't able to deduce which OS you
are writing this for; you mentioned inotify() which appears to be
Linux-specific, and you mentioned ext3 filesystems, which appear
to be Linux-specific, but you also mentioned NTFS filesystems,
which are proprietary to Microsoft Windows.
Yes my server must play on linux and win32
D'oh might be..
Anyone knows?
It's a great idea i'll search for win32 newsgroup and linux too
(suggested groups?)
anyone has a better idea????

What is the object of the assignment?
To explore efficient use
of tree structures, or to explore how one would implement OS
facilities if those facilities were not already provided?
is do a server for win and linux..
but the really problem is check in the better way,files deleted and
modified in filesystem ext3 Ntfs
:(

May 13 '07 #6
my final solution is :

save my bigs ntree in memory (i'm studing)
"Memory Mapped Files"
i hope it will be useful for the community.


May 13 '07 #7
elgiei wrote: *** and top-posted - fixed ***
rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
>elgiei <liug...@gmail.comwrote:
>>>
i have to implement a server,that every n-seconds (eg. 10sec)
sends to other clients,which files and directory has been
deleted or modified. i build a n-tree, for each files on harddisk
there's a node into n-tree,

this solution is not good for large hard disk.. and i can't use
inotify (it's forbidden), and only c solutions are accepted
without third party software or external calls. the Hard disk
are both ext3 and NTFS. anyone has a good idea for build an
efficient server??

No solution is possible within the constraints imposed. You are
only permitted to use C (you indicate), without third party
software or external calls, but you need external calls for two
or more aspects of the requirements:

1) C does not provide any mechanism to delay any particular
amount of time. The closest you can come is to "busy-loop", doing
some unnecessary work and checking the clock time to determine if
you've waited long enough. Busy-loops are inherently inefficient.
Most OS's provide means to delay for approximate times, but using
such an OS facility would be using an external call, not
permitted by your specifications.

2) C does not provide any mechanism to examine directories; C
doesn't know *anything* about directories. Most OS's provide
means to examine directories, but using such an OS facility would
be using an external call, not permitted by your specifications.

3) Your specifications require that information be periodically
"sent" to other clients. C does not provide any mechanims to
communicate with clients, other than whatever can be accomplished
with regular files. It is possible to come up with a reasonable
information dissemination method based upon writing out
information (pre-pended with the size of the information) to a
known file, but if you want to do a traditional client/server
architecture, you would have to use OS-specific facilities which
would require external calls, not permitted by your
specifications.
>>i build a n-tree, for each files on harddisk there's a node into
n-tree, this solution is not good for large hard disk..

How are you constructing your n-trees? Are you doing prefix-
sharing so that if you have figure1.eps and figure17.eps, the
"figure1" portion only gets stored once?

first of all thanks for your attention, my server already works
with pthread, socket, signal for timer and many feature offered by
includes, for external call i mean for example all the "exec" 's
family,whithin you can use any binary file on your /bin directory
(or .exe file).

my ntree has a lot of node, the same number of files and
directories. a node is composed by n pointer one for each son

so if my hard disk is composed only by :
/home/elgiei
/home/elgiei/file2.jpg
/home/elgiei/Desktop
/home/elgiei/Desktop/file1.jpg

my ntree is :

------/home/elgiei------------------------
--------- /--------\---------------------------
file2.jpg--------/home/elgiei/Desktop
-----------------------|-----------------------
------------------file1.jpg-------------------
(remove "-" with space)

after 60secs i rebuild a new ntree and i do a diff
(ntreeNEW,ntreeOLD) and i check the differences..
but it's not a smart solution for large data.

is there a signal Handler for catch file removed ?
anyone has a better idea????

i repeat the problem
i have to implement a server,that every n-seconds (eg. 10sec)
sends to other clients,which files and directory has been
deleted or modified in the system (not by my server)
the problem is catching the deleted or modified files,whitout an
expensive ntree snapshot.

a solution:
i can read all Hard disk and i can understand which files was
created or modified in the last 60-sec,
but i don't know about the deleted files.
I have preserved your entire post, less sigs, while fixing the
top-post.

Please do not top-post. Your answer belongs after (or intermixed
with) the quoted material to which you reply, after snipping all
irrelevant material. See the following links:

--
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/ (taming google)
<http://members.fortunecity.com/nnqweb/ (newusers)

--
Posted via a free Usenet account from http://www.teranews.com

May 13 '07 #8

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

Similar topics

25
by: Tim | last post by:
Dear Developers, Firstly, I'm not sure where this post should go so I apologise if this is in the wrong group or area. I'm currently interviewing for a vb.net developer who doesn't mind...
3
by: Joe | last post by:
Hi, I have written a webpage that allows a user to delete files in asp.net with I am having a small problem. To access this page a user has to login via login.aspx page. After successful...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
8
by: Chris | last post by:
Hi, All my websites and webservices are down. I get the following message Server Error in '/mywebservices' Application....
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
7
by: Enigma Curry | last post by:
I need to store a large number of files in an archive. From Python, I need to be able to create an archive, put files into it, modify files that are already in it, and delete files already in it. ...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
5
by: mike3 | last post by:
Hi. Is this a good idea?: <begin code> /* Addition operator: += */ const BigFix &BigFix::operator+=(const BigFix &rhs) { ErrorType err; int lhs_sign = sign, rhs_sign = rhs.sign;
10
by: George2 | last post by:
Hello everyone, Here is a sample from Dr. Dobb C++. In the analysis, the code is bad below. But I do not think the code is bad, 1. if bad_alloc is thrown in new int, we just catch it and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
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,...
0
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...

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.