logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

creat.3p (2781B)


  1. '\" et
  2. .TH CREAT "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. creat
  12. \(em create a new file or rewrite an existing one
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/stat.h>
  17. #include <fcntl.h>
  18. .P
  19. int creat(const char *\fIpath\fP, mode_t \fImode\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. The
  23. \fIcreat\fR()
  24. function shall behave as if it is implemented as follows:
  25. .sp
  26. .RS 4
  27. .nf
  28. int creat(const char *path, mode_t mode)
  29. {
  30. return open(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
  31. }
  32. .fi
  33. .P
  34. .RE
  35. .SH "RETURN VALUE"
  36. Refer to
  37. .IR "\fIopen\fR\^(\|)".
  38. .SH ERRORS
  39. Refer to
  40. .IR "\fIopen\fR\^(\|)".
  41. .LP
  42. .IR "The following sections are informative."
  43. .SH EXAMPLES
  44. .SS "Creating a File"
  45. .P
  46. The following example creates the file
  47. .BR /tmp/file
  48. with read and write permissions for the file owner and read permission
  49. for group and others. The resulting file descriptor is assigned to the
  50. .IR fd
  51. variable.
  52. .sp
  53. .RS 4
  54. .nf
  55. #include <fcntl.h>
  56. \&...
  57. int fd;
  58. mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
  59. char *pathname = "/tmp/file";
  60. \&...
  61. fd = creat(pathname, mode);
  62. \&...
  63. .fi
  64. .P
  65. .RE
  66. .SH "APPLICATION USAGE"
  67. None.
  68. .SH RATIONALE
  69. The
  70. \fIcreat\fR()
  71. function is redundant. Its services are also provided by the
  72. \fIopen\fR()
  73. function. It has been included primarily for historical purposes since
  74. many existing applications depend on it. It is best considered a part
  75. of the C binding rather than a function that should be provided in
  76. other languages.
  77. .SH "FUTURE DIRECTIONS"
  78. None.
  79. .SH "SEE ALSO"
  80. .IR "\fImknod\fR\^(\|)",
  81. .IR "\fIopen\fR\^(\|)"
  82. .P
  83. The Base Definitions volume of POSIX.1\(hy2017,
  84. .IR "\fB<fcntl.h>\fP",
  85. .IR "\fB<sys_stat.h>\fP",
  86. .IR "\fB<sys_types.h>\fP"
  87. .\"
  88. .SH COPYRIGHT
  89. Portions of this text are reprinted and reproduced in electronic form
  90. from IEEE Std 1003.1-2017, Standard for Information Technology
  91. -- Portable Operating System Interface (POSIX), The Open Group Base
  92. Specifications Issue 7, 2018 Edition,
  93. Copyright (C) 2018 by the Institute of
  94. Electrical and Electronics Engineers, Inc and The Open Group.
  95. In the event of any discrepancy between this version and the original IEEE and
  96. The Open Group Standard, the original IEEE and The Open Group Standard
  97. is the referee document. The original Standard can be obtained online at
  98. http://www.opengroup.org/unix/online.html .
  99. .PP
  100. Any typographical or formatting errors that appear
  101. in this page are most likely
  102. to have been introduced during the conversion of the source files to
  103. man page format. To report such errors, see
  104. https://www.kernel.org/doc/man-pages/reporting_bugs.html .