LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   file locking in linux? (https://www.linuxquestions.org/questions/linux-newbie-8/file-locking-in-linux-424992/)

sunpascal 03-15-2006 04:45 AM

file locking in linux?
 
Hi,
I have used Debian with KDE for a while now, after using Windows for a long time.
However, file locking is still a mystery to me. It seems files can be deleted even if an application still uses that file. And even more interesting, I can play a sound track after I deleted it. Is that normal?
On the other hand linux is very strict on umounting devices while files are still in use.
How does file locking work in linux anyways?

-Pascal

Gogul 03-15-2006 08:16 AM

that sounds a little funny to me :confused:

if you're referring to read/write access then you can easily change these by just loggin in as root (or whoever owns the r/w permissions) then going into the file properties.

Gogul 03-15-2006 08:18 AM

don't know if this will help

http://www.google.com/search?client=...UTF-8&oe=UTF-8

sunpascal 03-15-2006 08:35 AM

sorry, I wasn't clear.
I don't have a problem at all. I am just wondering: In windows, a program automatically locks a file if it reads or writes to it. Most linux programs don't seem to do that, right?

sunpascal 03-15-2006 08:38 AM

Also, how is it possible to listen to a sound track (with kaffeine) after you already deleted that file? It doesn't load it all into memory, does it?

Flesym 03-15-2006 08:49 AM

Look here:
http://en.wikipedia.org/wiki/File_locking

Gogul 03-15-2006 08:56 AM

That should answer your question though I think when you do play a sound file all of it is left in memory (depending on the size imho) though once you close kaffeine or reboot your computer you should no longer be able to access it.

I can't say if it applys to most linux programs.

Though I'm guessing no, I've noticed that sound tracks do for some reason remain in memory while they're been played.

if you can still access a sound track after closing the application or rebooting your computer then I've no idea why you'd still be able to listen to it once you've deleted it.

http://linux.oneandoneis2.org/LNW.htm

chrism01 03-15-2006 05:37 PM

The unlink cmd (=delete) removes the inode entry, but if a prog currently has the file open, it will continue to exist until the prog closes it.
Handy for more secure (invisible) temp files; see articles on CGI uploads for example.
For full explanation:
http://hissa.nist.gov/rbac/titleissues/node26.html

sundialsvcs 03-15-2006 08:00 PM

Ahh, one of the magic features of Linux.

In the Linux/Unix system, a file is an inode structure. (Don't ask me why it's called an "inode.") Physically speaking, that on-disk structure is the thing .. the only thing .. that actually represents a file.

Directory entries point to the inode. The original directory-entry always does, and additional hard-links can be defined to do so as well.

Anyhow... the file-locking philosophies of Unix vs. Windows are not quite the same. You can read considerably about it on the web.


All times are GMT -5. The time now is 06:25 PM.