|
From: Guido V. <gu...@vi...> - 2006-01-15 19:04:27
|
Hello, in my filesystem, I have to perform a particular action when a file is created. Before version 2.5 it was straightforward: a file is only created within an `mknod' call, `open' never creates a file. In version 2.5 I find the `create' system call, which reads "If the file does not exist, first create it with the specified mode, and then open it.". I have a few doubts: 1. what does happen if the file exists? Is it truncated like in `creat'? 2. Does this call ever get used when the file exists? I made a small program where I only call a `creat', and I saw that: - `create' is used when the file does not exists; - `truncate' and `open' (why not `open' and `ftruncate'?) are used when the file is already existing. May I assume that `create' always creates a file, and is never called on an already existing file? Should this be true, I could perform my "new file" action without having to `stat' the file before to check if the file is existing... Thank you very much, Guido |