-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/fs/mkstemp/: mkostemp(): Split API from fmkomstemp()
This reduces the complexity of fmkomstemp(). Signed-off-by: Alejandro Colomar <[email protected]>
- Loading branch information
1 parent
aa3d367
commit dae656e
Showing
4 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#include <config.h> | ||
|
||
#include "fs/mkstemp/mkomstemp.h" | ||
|
||
#include <sys/types.h> | ||
|
||
|
||
extern inline int mkomstemp(char *template, unsigned int flags, mode_t m); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#ifndef SHADOW_INCLUDE_LIB_FS_MKSTEMP_MKOMSTEMP_H_ | ||
#define SHADOW_INCLUDE_LIB_FS_MKSTEMP_MKOMSTEMP_H_ | ||
|
||
|
||
#include <config.h> | ||
|
||
#include <stdlib.h> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
|
||
inline int mkomstemp(char *template, unsigned int flags, mode_t m); | ||
|
||
|
||
inline int | ||
mkomstemp(char *template, unsigned int flags, mode_t m) | ||
{ | ||
int fd; | ||
|
||
fd = mkostemp(template, flags); | ||
if (fd == -1) | ||
return -1; | ||
|
||
if (fchmod(fd, m) == -1) | ||
goto fail; | ||
|
||
return fd; | ||
fail: | ||
close(fd); | ||
unlink(template); | ||
return -1; | ||
} | ||
|
||
|
||
#endif // include guard |