Открываем файл,

User avatar
Strannik223
Уже с Приветом
Posts: 569
Joined: 14 Dec 2003 04:06
Location: Львов->Киев->Торонто

Post by Strannik223 »

tengiz wrote:
Strannik223 wrote:
As a side note, Windows locking does not check properly for file permissions before attempting to lock a file, only when actually reading/writing data to the file. This presents a security risk, as a malignent program could conceivably block access to all files on the disk by locking them exclusively.

The side note is wrong. LockFile/LockFileEx specificly require read or write access right on the file handle they operate.


Может это давно было. И неправда. :mrgreen:
Никакой разрухи нет. (с) Проф. Преображенский.
vc
Уже с Приветом
Posts: 664
Joined: 05 Jun 2002 01:11

Post by vc »

A. Fig Lee wrote:
vc wrote:
A. Fig Lee wrote:На Солярке ага, производит еррор.
Кстати, на FreeBSD ета система не сработала.
fcntl rules без всяких мандатори локс.


OK, so you proved that Solaris 9 has mandatory locking and FreeBSD (whatever it is) does not.

Что значит "мандатори локинг"? fcntl работает.


It's unclear what you mean by 'fcntl works'. Sure it works for co-operating processes (as flock/lockf would). But since you want to protect your file from being overwritten by any arbitrary process, fcntl would not 'work' in FreeBSD precisely because the OS does not implement mandatory locking.

A. Fig Lee wrote:Хммм... Тот лок что Вы тут описывали и пропагандировали имплементед сверху fcntl.

Code: Select all

man flock

Если fcntl просто интерфейс, то flock и подавно.


You should read what I wrote more carefully -- I used lockf (which is indeed a simplified interface to fcntl), not flock, but that's beside the point as fcntl would not 'work' for non-cooperating processes under FreeBSD anyway. A 'cp', for example, will happily overwrite a 'locked' file in FreebSD, lock or no lock.

VC

Return to “Вопросы и новости IT”