Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steamrt
steam-runtime-tools
Commits
a5b76690
Commit
a5b76690
authored
4 years ago
by
Rebecca Turner
Browse files
Options
Downloads
Patches
Plain Diff
glnx-fdio: use $TMPDIR if set
As suggested by Colin Walters.
parent
1ea9158c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
glnx-fdio.c
+6
-33
6 additions, 33 deletions
glnx-fdio.c
with
6 additions
and
33 deletions
glnx-fdio.c
+
6
−
33
View file @
a5b76690
...
...
@@ -303,8 +303,8 @@ glnx_open_anonymous_tmpfile_full (int flags,
}
/* A variant of `glnx_open_tmpfile_linkable_at()` which doesn't support linking.
* Useful for true temporary storage. The fd will be allocated in `
/var/tmp`
*
(or `$TMPDIR` if `/var/tmp` doesn't exist) to ensure maximum storage spac
e.
* Useful for true temporary storage. The fd will be allocated in `
$TMPDIR` if
*
set or `/var/tmp` otherwis
e.
*
* If you need the file on a specific filesystem use glnx_open_anonymous_tmpfile_full()
* which lets you pass a directory.
...
...
@@ -314,37 +314,10 @@ glnx_open_anonymous_tmpfile (int flags,
GLnxTmpfile
*
out_tmpf
,
GError
**
error
)
{
if
(
glnx_open_anonymous_tmpfile_full
(
flags
,
"/var/tmp"
,
out_tmpf
,
error
))
return
TRUE
;
else
if
((
*
error
)
->
code
==
G_IO_ERROR_NOT_FOUND
)
{
/* If /var/tmp doesn't exist, such as in a NixOS build or
* other constrained systems, this will fail.
*
* Therefore, we try again using the directory in $TMPDIR if possible.
*/
const
char
*
tmpdir
=
getenv
(
"TMPDIR"
);
if
(
tmpdir
==
NULL
)
return
FALSE
;
GError
*
tmp_error
;
tmp_error
=
NULL
;
if
(
!
glnx_open_anonymous_tmpfile_full
(
flags
,
tmpdir
,
out_tmpf
,
&
tmp_error
))
{
g_propagate_error
(
error
,
tmp_error
);
return
FALSE
;
}
else
{
// Don't leave the error from the first call to
// glnx_open_anonymous_tmpfile_full in `error`.
g_clear_error
(
error
);
return
TRUE
;
}
}
else
return
FALSE
;
return
glnx_open_anonymous_tmpfile_full
(
flags
,
getenv
(
"TMPDIR"
)
?:
"/var/tmp"
,
out_tmpf
,
error
);
}
/* Use this after calling glnx_open_tmpfile_linkable_at() to give
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment