04-29-2011
Quote:
The open man page says:
The argument mode specifies the permissions to use in case a new file is created. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask). Note that this mode only applies to future accesses of the newly created file; the open() call that creates a read-only file may well return a read/write file descriptor.
Yeah, right. Thanks.
But if the file.txt has not the right permission, I'd expect a "file creation failed..." error message?
Cheers, Loïc
10 More Discussions You Might Find Interesting
1. Programming
I am using gdb to examine a core file but the output contains only the method addresses in hex.
Is there anyway to translate these addresses to a human-readable form? :confused: (0 Replies)
Discussion started by: ciregbu
0 Replies
2. HP-UX
Hi,
Files coming to mailbox are in readable format?
Is there any special command to read these files.
suppose i have sent a file like this
megh$mailx -s "mesg" xyz@server.domain<file1.dat
can xyz directly read the file from his mailbox? (1 Reply)
Discussion started by: megh
1 Replies
3. UNIX for Dummies Questions & Answers
In Unix/Ksh, when I try to look inside a file it says that the file may be a binary file and if I want to see it anyway. When i say 'yes', it shows me the content filled with unreadable symbols (looks like binary). Is there a command that I can run from the Unix prompt to convert/translate that... (3 Replies)
Discussion started by: arthurs
3 Replies
4. UNIX for Dummies Questions & Answers
$ quota
Disk quotas for user cqlouis (uid 1254):
Filesystem blocks quota limit grace files quota limit grace
/dev/sdb1 64 300000 320000 8 0 0
$
I want to make the output of command quota in human readable format? How to?
As we... (2 Replies)
Discussion started by: cqlouis
2 Replies
5. Shell Programming and Scripting
i want to check the readability of a file inside the script.
when i use
if
then
echo the file "$sourcef" is not readable
else
echo something
fi
i am getting the error : f: unknown test operator
when i tried to check the availability with
if
i was... (3 Replies)
Discussion started by: gotam
3 Replies
6. Shell Programming and Scripting
All,
I have a script where I get a filename as input and do some processing with the file that I got as input.
Requirement:
Now I have a requirement where I need to check the following:
If either of this goes wrong, the script should pop out a warning message.
I tried searching the... (6 Replies)
Discussion started by: bharath.gct
6 Replies
7. Shell Programming and Scripting
hi all,
in ksh script how do i detect if a file is readable by others ??
thanks. (6 Replies)
Discussion started by: cesarNZ
6 Replies
8. Shell Programming and Scripting
Hi, I'm writing an awk script to remove redundant XML data.
I plan on running the script with the following line:
cat xmlFile.xml | awk -f scriptFile
I want the user to be able to choose the filename that the slimmed down XML code is written to. All of the writing to the slimmed-file is... (2 Replies)
Discussion started by: jeg90
2 Replies
9. UNIX for Dummies Questions & Answers
When I do the file I get ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped
I am almost 100% sure I was able to print a readable version of this file in the past but I cannot remember how. Is it possible to convert this file into something that can be read and or... (3 Replies)
Discussion started by: fsanchez
3 Replies
10. Shell Programming and Scripting
Hello I have a file : file1.txt with the below contents :
237176 test1 test2 1442149024
237138 test3 test4 1442121300
237171 test5 test7 1442112823
237145 test9 test10 1442109600
In the above file fourth field represents the timestamp in Unix format.
I found a command which converts... (6 Replies)
Discussion started by: rahul2662
6 Replies
OPEN(5) File Formats Manual OPEN(5)
NAME
open, create - prepare a fid for I/O on an existing or new file
SYNOPSIS
Topen tag[2] fid[2] mode[1]
Ropen tag[2] fid[2] qid[8]
Tcreate tag[2] fid[2] name[28] perm[4] mode[1]
Rcreate tag[2] fid[2] qid[8]
DESCRIPTION
The open request asks the file server to check permissions and prepare a fid for I/O with subsequent read and write messages. The mode
field determines the type of I/O: 0, 1, 2, and 3 mean read access, write access, read and write access, and execute access, to be checked
against the permissions for the file. In addition, if mode has the OTRUNC (0x10) bit set, the file is to be truncated, which requires
write permission (if the file is append-only, and permission is granted, the open succeeds but the file will not be truncated); if the mode
has the ORCLOSE (0x40) bit set, the file is to be removed when the fid is clunked, which requires permission to remove the file from its
directory. If other bits are set in mode they will be ignored. It is illegal to write a directory, truncate it, or attempt to remove it
on close. If the file is marked for exclusive use (see stat(5)), only one client can have the file open at any time. That is, after such
a file has been opened, no other open will succeed until fid has been clunked. All these permissions are checked at the time of the open
request; subsequent changes to the permissions of files do not affect the ability to read, write, or remove an open file.
The create request asks the file server to create a new file with the name supplied, in the directory (dir) represented by fid, and
requires write permission in the directory. The owner of the file is the implied user id of the request, the group of the file is the same
as dir, and the permissions are the value of
(perm&(~0777|0111)) | (dir.perm&perm&0666)
if a regular file is being created and
(perm&~0777) | (dir.perm&perm&0777)
if a directory is being created. This means, for example, that if the create allows read permission to others, but the containing direc-
tory does not, then the created file will not allow others to read the file.
Finally, the newly created file is opened according to mode, and fid will represent the newly opened file. Mode is not checked against the
permissions in perm. The qid for the new file is returned with the create reply message.
Directories are created by setting the CHDIR bit (0x80000000) in the perm.
The names . and .. are special; it is illegal to create files with these names.
It is an error for either of these messages if the fid is already the product of a successful open or create message.
An attempt to create a file in a directory where the given name already exists will be rejected; in this case, the create system call (see
open(2)) uses open with truncation. The algorithm used by create is: first walk to the directory to contain the file. If that fails,
return an error. Next walk to the specified file. If the walk succeeds, send a request to open and truncate the file and return the
result, successful or not. If the walk fails, send a create message. If that fails, it may be because the file was created by another
process after the previous walk failed, so (once) try the walk and open again. For the behavior of create on a union directory, see
bind(2).
ENTRY POINTS
Open and create both generate open messages; only create generates a create message.
OPEN(5)