Skip to contentSkip to conversation

What's the mean of FMODE_EXCL?

DISCUSSION majianpeng 1 participant 1 message Nov 21, 2012 VFS

lore
Share & tools
lore

majianpeng

author
#0 lore raw

Hi all:
Today, i wrote to a partition which already mounted using dd.So the fs was destroyed completedly.
So i asked why dd can write? I remembed the flag O_EXCL which prevent other operation.
I review the code and found it used FMODE_EXCL.But why dd can write?
In open(2):

Quoted 4 lines

In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one
exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a
block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

But understand from the literal meaning, EXCL means opened exclusively.I think it like mutex-operation.
Can someone please tell me why?

Thanks!
Jianpeng