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
8cdbef77
Unverified
Commit
8cdbef77
authored
Feb 15, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add development helper to quickly dump a directories contents
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
e7e45fdf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
utils.c
src/lxc/utils.c
+50
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
8cdbef77
...
@@ -1855,3 +1855,53 @@ bool multiply_overflow(int64_t base, uint64_t mult, int64_t *res)
...
@@ -1855,3 +1855,53 @@ bool multiply_overflow(int64_t base, uint64_t mult, int64_t *res)
*
res
=
base
*
mult
;
*
res
=
base
*
mult
;
return
true
;
return
true
;
}
}
int
print_r
(
int
fd
,
const
char
*
path
)
{
__do_close
int
dfd
=
-
EBADF
;
__do_closedir
DIR
*
dir
=
NULL
;
int
ret
=
0
;
struct
dirent
*
direntp
;
struct
stat
st
;
if
(
is_empty_string
(
path
))
dfd
=
dup
(
fd
);
else
dfd
=
openat
(
fd
,
path
,
O_CLOEXEC
|
O_DIRECTORY
);
if
(
dfd
<
0
)
return
-
1
;
dir
=
fdopendir
(
dfd
);
if
(
!
dir
)
return
-
1
;
/* Transfer ownership to fdopendir(). */
move_fd
(
dfd
);
while
((
direntp
=
readdir
(
dir
)))
{
if
(
!
strcmp
(
direntp
->
d_name
,
"."
)
||
!
strcmp
(
direntp
->
d_name
,
".."
))
continue
;
ret
=
fstatat
(
dfd
,
direntp
->
d_name
,
&
st
,
AT_SYMLINK_NOFOLLOW
);
if
(
ret
<
0
&&
errno
!=
ENOENT
)
break
;
ret
=
0
;
if
(
S_ISDIR
(
st
.
st_mode
))
ret
=
print_r
(
dfd
,
direntp
->
d_name
);
else
INFO
(
"mode(%o):uid(%d):gid(%d) -> %s/%s
\n
"
,
(
st
.
st_mode
&
~
S_IFMT
),
st
.
st_uid
,
st
.
st_gid
,
path
,
direntp
->
d_name
);
if
(
ret
<
0
&&
errno
!=
ENOENT
)
break
;
}
ret
=
fstatat
(
fd
,
path
,
&
st
,
AT_SYMLINK_NOFOLLOW
);
if
(
ret
)
return
-
1
;
else
INFO
(
"mode(%o):uid(%d):gid(%d) -> %s"
,
(
st
.
st_mode
&
~
S_IFMT
),
st
.
st_uid
,
st
.
st_gid
,
path
);
return
ret
;
}
src/lxc/utils.h
View file @
8cdbef77
...
@@ -243,5 +243,6 @@ __hidden extern int safe_mount_beneath(const char *beneath, const char *src, con
...
@@ -243,5 +243,6 @@ __hidden extern int safe_mount_beneath(const char *beneath, const char *src, con
const
char
*
fstype
,
unsigned
int
flags
,
const
void
*
data
);
const
char
*
fstype
,
unsigned
int
flags
,
const
void
*
data
);
__hidden
extern
int
safe_mount_beneath_at
(
int
beneat_fd
,
const
char
*
src
,
const
char
*
dst
,
__hidden
extern
int
safe_mount_beneath_at
(
int
beneat_fd
,
const
char
*
src
,
const
char
*
dst
,
const
char
*
fstype
,
unsigned
int
flags
,
const
void
*
data
);
const
char
*
fstype
,
unsigned
int
flags
,
const
void
*
data
);
__hidden
__lxc_unused
int
print_r
(
int
fd
,
const
char
*
path
);
#endif
/* __LXC_UTILS_H */
#endif
/* __LXC_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