Google Answers Logo
View Question
 
Q: Temporarily locking files on a server. ( No Answer,   2 Comments )
Question  
Subject: Temporarily locking files on a server.
Category: Computers > Operating Systems
Asked by: civitas-ga
List Price: $20.00
Posted: 25 Feb 2006 08:43 PST
Expires: 27 Mar 2006 08:43 PST
Question ID: 700829
Our company just purchased a new server to help us in the networking
of five computers.  We want to protect ourselves against more than one
person working on a single file at the same time and then saving the
file with only one of the person's changes to the file.

Is there a program or a hardware setting so that when a file on a
server is being used by one person no other user can access it (or
only access it in a read-only format)?  We want to have a "clean
server" in which users do not lose changes that they have made to a
file.  By the way, we are using Windows XP Professional.  Thanks so
much!  -- Arthur
Answer  
There is no answer at this time.

Comments  
Subject: Re: Temporarily locking files on a server.
From: irlandes-ga on 03 Mar 2006 20:33 PST
 
Interesting question to me for special reason. I am in a small
mountain village in rural Puebla, Mexico.  My wife was born and raised
here. I am a Linux geek, and last year gave some free, and open CD's
to a local man who runs the computer in a local school for indigenous
adults.

In the fall, when I came back, he told me she was nearly done with her
college work as a computer engineer. She had only her thesis project
left. And, it was to write a program to lock a file on a server when
someone accesses that file, just as you have stated.  She said that
sounded easy, but her professor added the requirement that it be
demonstrated in Linux.

Here in Mexico, one has to pay for everything, things we do for each
other free in the US. So, to get classes in Linux, she would have to
pay considerable money.  She had the Knoppix CD's I gave Jorge, but
didn't know enough about Linux to do the job. She felt the lock
program was easy, but didn't even know how to run commands in Linux.

So, for a week I gave her FREE classes in Linux.  They were very
pleased when I refused to take any money for what I most like to do. 
The last I heard, she had demonstrated the program to her professor,
but he told her she needed to demonstrate it to all the computer
professors.

So, I can guarantee you such a program exists, and I also assume it
can be easily ported for Windows.  In my experience, such assignments
are given because the professors want them to use.  I think, alas,
there is a rule that we are not supposed to have direct contact by
posting our email address here, or I would open communications by that
path. Sorry.
Subject: Re: Temporarily locking files on a server.
From: cisc-ga on 05 Mar 2006 20:51 PST
 
Hello civitas,

what you want is called File locking system.
If you're using WinXP Pro, try to install windows 2K or 2003 server on
your new server. Employ an active directory in server with all 5
computer on the network as the clients of the domain.

You could hire engineer to do this, do your self if you can.
finally if Active directory is set, then save files that you want only one
user per time over the network and share it. you do this on your
Active directory server.

Below is a brief of File locking terminology. 

File locking in Windows

Program files are automatically locked upon execution, thus preventing
them from being modified or deleted while running. Programs are
automatically notified if an open file is being modified by an
external program. File locking in Windows is referred to as mandatory
locking, since locks are enforced by the operating system.

The Windows locking approach can result in problems where the
operating system or an application crashes without being terminated
properly. This leads to a situation where access is denied to files
even though they do not appear to be in use, because the operating
system or a crashed application still has a lock on the file. The user
will in this case have to terminate a program manually to remove the
lock. This is typically done through the Task Manager utility.

File locking permissions are determined by the sharing mode parameter
in the LockFile function or the CreateFile function used to open
files. This parameter may be either exclusive, shared read and/or
shared write. The ReadDirectoryChangesW function can be used for
notification of external changes to files opened in non exclusive
mode.

Locked files, also known as file handles in Windows, can be explored
with the Process Explorer utility. This utility can also be used to
force-close handles without needing to terminate the application
holding them.


File locking in UNIX

Open files and programs are not automatically locked in UNIX. There
are different kinds of file locking mechanisms available in different
flavours of UNIX and many operating systems support more than one kind
for compatibility. The two most common mechanisms are fcntl and flock.
Although some types of locks can be configured to be mandatory, file
locks under UNIX are by default advisory. This means that cooperating
processes may use locks to coordinate access to a file between
themselves, but programs are also free to ignore locks and access the
file in any way they choose to.

Two kinds of locks are offered: shared locks and exclusive locks. In
the case of fcntl, different kinds of locks may be applied to
different sections (byte ranges) of a file, or else to the whole file.
Shared locks can be acquired by an unlimited number of processes at
the same time, but an exclusive lock can only be acquired by one
process, and cannot coexist with a shared lock. To acquire a shared
lock, a process must wait until there are no processes holding any
exclusive locks. To acquire an exclusive lock, a process must wait
until there are no processes holding either kind of lock.

Shared locks are sometimes called "read locks" and exclusive locks are
sometimes called "write locks". However, because locks on UNIX are
advisory, this isn't enforced. Thus it is possible for a database to
have a concept of "shared writes" vs. "exclusive writes"; for example,
changing a field in place may be permitted under shared access,
whereas garbage-collecting and rewriting the database may require
exclusive access.

This combination of inode usage and non-mandatory locking leads to
great flexibility in accessing files from multiple processes. On the
other hand, the cooperative locking approach can lead to problems when
a process writes to a file without obeying file locks set by other
processes. For this reason, some UNIX and UNIX-like operating systems
support mandatory locking as well.


Best, 
Adha

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy