-
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/, src/: fmkomstemp(): Move function to separate file
And make it inline. Signed-off-by: Alejandro Colomar <[email protected]>
- Loading branch information
1 parent
90afe61
commit aa3d367
Showing
4 changed files
with
62 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#include <config.h> | ||
|
||
#include "fs/mkstemp/fmkomstemp.h" | ||
|
||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
|
||
extern inline FILE *fmkomstemp(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,46 @@ | ||
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#ifndef SHADOW_INCLUDE_LIB_FS_MKSTEMP_FMKOMSTEMP_H_ | ||
#define SHADOW_INCLUDE_LIB_FS_MKSTEMP_FMKOMSTEMP_H_ | ||
|
||
|
||
#include <config.h> | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
|
||
inline FILE *fmkomstemp(char *template, unsigned int flags, mode_t m); | ||
|
||
|
||
inline FILE * | ||
fmkomstemp(char *template, unsigned int flags, mode_t m) | ||
{ | ||
int fd; | ||
FILE *fp; | ||
|
||
fd = mkostemp(template, flags); | ||
if (fd == -1) | ||
return NULL; | ||
|
||
if (fchmod(fd, m) == -1) | ||
goto fail; | ||
|
||
fp = fdopen(fd, "w"); | ||
if (fp == NULL) | ||
goto fail; | ||
|
||
return fp; | ||
fail: | ||
close(fd); | ||
unlink(template); | ||
return NULL; | ||
} | ||
|
||
|
||
#endif // include guard |
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