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
60c613df
Unverified
Commit
60c613df
authored
Feb 11, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file_utils: add same_file_lax()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
00c5cdf0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
file_utils.c
src/lxc/file_utils.c
+23
-0
file_utils.h
src/lxc/file_utils.h
+8
-0
No files found.
src/lxc/file_utils.c
View file @
60c613df
...
@@ -725,3 +725,26 @@ char *read_file_at(int dfd, const char *fnam,
...
@@ -725,3 +725,26 @@ char *read_file_at(int dfd, const char *fnam,
return
move_ptr
(
buf
);
return
move_ptr
(
buf
);
}
}
bool
same_file_lax
(
int
fda
,
int
fdb
)
{
struct
stat
st_fda
,
st_fdb
;
if
(
fda
==
fdb
)
return
true
;
if
(
fstat
(
fda
,
&
st_fda
)
<
0
)
return
false
;
if
(
fstat
(
fdb
,
&
st_fdb
)
<
0
)
return
false
;
errno
=
EINVAL
;
if
((
st_fda
.
st_mode
&
S_IFMT
)
!=
(
st_fdb
.
st_mode
&
S_IFMT
))
return
false
;
errno
=
EINVAL
;
return
(
st_fda
.
st_dev
==
st_fdb
.
st_dev
)
&&
(
st_fda
.
st_ino
==
st_fdb
.
st_ino
);
}
src/lxc/file_utils.h
View file @
60c613df
...
@@ -96,4 +96,12 @@ __hidden extern char *read_file_at(int dfd, const char *fnam,
...
@@ -96,4 +96,12 @@ __hidden extern char *read_file_at(int dfd, const char *fnam,
__hidden
extern
ssize_t
lxc_read_try_buf_at
(
int
dfd
,
const
char
*
path
,
__hidden
extern
ssize_t
lxc_read_try_buf_at
(
int
dfd
,
const
char
*
path
,
void
*
buf
,
size_t
count
);
void
*
buf
,
size_t
count
);
/*
* Check if two fds refer to the same file.
* The function is "lax" in so far, as it doesn't care whether fda and fdb have
* the same flags or whether they share the same device context when they refer
* to devices.
*/
__hidden
extern
bool
same_file_lax
(
int
fda
,
int
fdb
);
#endif
/* __LXC_FILE_UTILS_H */
#endif
/* __LXC_FILE_UTILS_H */
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