Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
6f61472b
Unverified
Commit
6f61472b
authored
Aug 09, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file_utils: add exists_dir_at()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ae9215cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
file_utils.c
src/lxc/file_utils.c
+12
-0
file_utils.h
src/lxc/file_utils.h
+1
-0
utils.c
src/lxc/utils.c
+1
-9
No files found.
src/lxc/file_utils.c
View file @
6f61472b
...
@@ -539,3 +539,15 @@ int timens_offset_write(clockid_t clk_id, int64_t s_offset, int64_t ns_offset)
...
@@ -539,3 +539,15 @@ int timens_offset_write(clockid_t clk_id, int64_t s_offset, int64_t ns_offset)
return
0
;
return
0
;
}
}
bool
exists_dir_at
(
int
dir_fd
,
const
char
*
path
)
{
struct
stat
sb
;
int
ret
;
ret
=
fstatat
(
dir_fd
,
path
,
&
sb
,
0
);
if
(
ret
<
0
)
return
false
;
return
S_ISDIR
(
sb
.
st_mode
);
}
src/lxc/file_utils.h
View file @
6f61472b
...
@@ -73,5 +73,6 @@ __hidden extern int lxc_open_dirfd(const char *dir);
...
@@ -73,5 +73,6 @@ __hidden extern int lxc_open_dirfd(const char *dir);
__hidden
extern
FILE
*
fdopen_cached
(
int
fd
,
const
char
*
mode
,
void
**
caller_freed_buffer
);
__hidden
extern
FILE
*
fdopen_cached
(
int
fd
,
const
char
*
mode
,
void
**
caller_freed_buffer
);
__hidden
extern
FILE
*
fopen_cached
(
const
char
*
path
,
const
char
*
mode
,
void
**
caller_freed_buffer
);
__hidden
extern
FILE
*
fopen_cached
(
const
char
*
path
,
const
char
*
mode
,
void
**
caller_freed_buffer
);
__hidden
extern
int
timens_offset_write
(
clockid_t
clk_id
,
int64_t
s_offset
,
int64_t
ns_offset
);
__hidden
extern
int
timens_offset_write
(
clockid_t
clk_id
,
int64_t
s_offset
,
int64_t
ns_offset
);
__hidden
extern
bool
exists_dir_at
(
int
dir_fd
,
const
char
*
path
);
#endif
/* __LXC_FILE_UTILS_H */
#endif
/* __LXC_FILE_UTILS_H */
src/lxc/utils.c
View file @
6f61472b
...
@@ -569,15 +569,7 @@ gid_t get_ns_gid(gid_t orig)
...
@@ -569,15 +569,7 @@ gid_t get_ns_gid(gid_t orig)
bool
dir_exists
(
const
char
*
path
)
bool
dir_exists
(
const
char
*
path
)
{
{
struct
stat
sb
;
return
exists_dir_at
(
-
1
,
path
);
int
ret
;
ret
=
stat
(
path
,
&
sb
);
if
(
ret
<
0
)
/* Could be something other than eexist, just say "no". */
return
false
;
return
S_ISDIR
(
sb
.
st_mode
);
}
}
/* Note we don't use SHA-1 here as we don't want to depend on HAVE_GNUTLS.
/* Note we don't use SHA-1 here as we don't want to depend on HAVE_GNUTLS.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment