[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Specifying a mode to open when O_CREAT is used
From: |
Jose E. Marchesi |
Subject: |
Specifying a mode to open when O_CREAT is used |
Date: |
Wed, 17 Mar 2021 15:13:38 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Egeyar, all.
open(2) says that a third argument `mode' is to be provided to `open'
when O_CREAT is specified in the flags.
The specified mode is then combined with the umask to mount the
permissions for the newly created file (for future accesses). Right now
these permissions are none.
So we have to specify a set of reasonable permissions.
What about this:
open (handler, flags_for_open,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Note that the `mode' third argument to `open' is ignored if O_CREAT is
not in `flags'.
WDYT?
- Specifying a mode to open when O_CREAT is used,
Jose E. Marchesi <=