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
4e57e9dc
Commit
4e57e9dc
authored
Nov 22, 2016
by
Stéphane Graber
Committed by
GitHub
Nov 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1310 from brauner/2016-11-22/tree_wide_replace_readdir_r
tree-wide: replace readdir_r() with readdir()
parents
edb1098b
78c284c7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
36 deletions
+20
-36
bdev.c
src/lxc/bdev.c
+2
-2
cgfs.c
src/lxc/cgfs.c
+4
-19
conf.c
src/lxc/conf.c
+3
-4
confile.c
src/lxc/confile.c
+1
-1
lxccontainer.c
src/lxc/lxccontainer.c
+6
-6
start.c
src/lxc/start.c
+2
-2
utils.c
src/lxc/utils.c
+2
-2
No files found.
src/lxc/bdev.c
View file @
4e57e9dc
...
@@ -1897,7 +1897,7 @@ static int loop_detect(const char *path)
...
@@ -1897,7 +1897,7 @@ static int loop_detect(const char *path)
static
int
find_free_loopdev_no_control
(
int
*
retfd
,
char
*
namep
)
static
int
find_free_loopdev_no_control
(
int
*
retfd
,
char
*
namep
)
{
{
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
struct
loop_info64
lo
;
struct
loop_info64
lo
;
DIR
*
dir
;
DIR
*
dir
;
int
fd
=
-
1
;
int
fd
=
-
1
;
...
@@ -1907,8 +1907,8 @@ static int find_free_loopdev_no_control(int *retfd, char *namep)
...
@@ -1907,8 +1907,8 @@ static int find_free_loopdev_no_control(int *retfd, char *namep)
SYSERROR
(
"Error opening /dev"
);
SYSERROR
(
"Error opening /dev"
);
return
-
1
;
return
-
1
;
}
}
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
((
direntp
=
readdir
(
dir
)))
{
if
(
!
direntp
)
if
(
!
direntp
)
break
;
break
;
if
(
strncmp
(
direntp
->
d_name
,
"loop"
,
4
)
!=
0
)
if
(
strncmp
(
direntp
->
d_name
,
"loop"
,
4
)
!=
0
)
...
...
src/lxc/cgfs.c
View file @
4e57e9dc
...
@@ -155,7 +155,7 @@ static struct cgroup_ops cgfs_ops;
...
@@ -155,7 +155,7 @@ static struct cgroup_ops cgfs_ops;
static
int
cgroup_rmdir
(
char
*
dirname
)
static
int
cgroup_rmdir
(
char
*
dirname
)
{
{
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
int
saved_errno
=
0
;
int
saved_errno
=
0
;
DIR
*
dir
;
DIR
*
dir
;
int
ret
,
failed
=
0
;
int
ret
,
failed
=
0
;
...
@@ -167,7 +167,7 @@ static int cgroup_rmdir(char *dirname)
...
@@ -167,7 +167,7 @@ static int cgroup_rmdir(char *dirname)
return
-
1
;
return
-
1
;
}
}
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
(
(
direntp
=
readdir
(
dir
)
))
{
struct
stat
mystat
;
struct
stat
mystat
;
int
rc
;
int
rc
;
...
@@ -2068,26 +2068,14 @@ out:
...
@@ -2068,26 +2068,14 @@ out:
static
int
cgroup_recursive_task_count
(
const
char
*
cgroup_path
)
static
int
cgroup_recursive_task_count
(
const
char
*
cgroup_path
)
{
{
DIR
*
d
;
DIR
*
d
;
struct
dirent
*
dent_buf
;
struct
dirent
*
dent
;
struct
dirent
*
dent
;
ssize_t
name_max
;
int
n
=
0
,
r
;
int
n
=
0
,
r
;
/* see man readdir_r(3) */
name_max
=
pathconf
(
cgroup_path
,
_PC_NAME_MAX
);
if
(
name_max
<=
0
)
name_max
=
255
;
dent_buf
=
malloc
(
offsetof
(
struct
dirent
,
d_name
)
+
name_max
+
1
);
if
(
!
dent_buf
)
return
-
1
;
d
=
opendir
(
cgroup_path
);
d
=
opendir
(
cgroup_path
);
if
(
!
d
)
{
if
(
!
d
)
free
(
dent_buf
);
return
0
;
return
0
;
}
while
(
readdir_r
(
d
,
dent_buf
,
&
dent
)
==
0
&&
dent
)
{
while
(
(
dent
=
readdir
(
d
))
)
{
const
char
*
parts
[
3
]
=
{
const
char
*
parts
[
3
]
=
{
cgroup_path
,
cgroup_path
,
dent
->
d_name
,
dent
->
d_name
,
...
@@ -2101,13 +2089,11 @@ static int cgroup_recursive_task_count(const char *cgroup_path)
...
@@ -2101,13 +2089,11 @@ static int cgroup_recursive_task_count(const char *cgroup_path)
sub_path
=
lxc_string_join
(
"/"
,
parts
,
false
);
sub_path
=
lxc_string_join
(
"/"
,
parts
,
false
);
if
(
!
sub_path
)
{
if
(
!
sub_path
)
{
closedir
(
d
);
closedir
(
d
);
free
(
dent_buf
);
return
-
1
;
return
-
1
;
}
}
r
=
stat
(
sub_path
,
&
st
);
r
=
stat
(
sub_path
,
&
st
);
if
(
r
<
0
)
{
if
(
r
<
0
)
{
closedir
(
d
);
closedir
(
d
);
free
(
dent_buf
);
free
(
sub_path
);
free
(
sub_path
);
return
-
1
;
return
-
1
;
}
}
...
@@ -2123,7 +2109,6 @@ static int cgroup_recursive_task_count(const char *cgroup_path)
...
@@ -2123,7 +2109,6 @@ static int cgroup_recursive_task_count(const char *cgroup_path)
free
(
sub_path
);
free
(
sub_path
);
}
}
closedir
(
d
);
closedir
(
d
);
free
(
dent_buf
);
return
n
;
return
n
;
}
}
...
...
src/lxc/conf.c
View file @
4e57e9dc
...
@@ -590,7 +590,7 @@ out:
...
@@ -590,7 +590,7 @@ out:
static
int
mount_rootfs_file
(
const
char
*
rootfs
,
const
char
*
target
,
static
int
mount_rootfs_file
(
const
char
*
rootfs
,
const
char
*
target
,
const
char
*
options
)
const
char
*
options
)
{
{
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
struct
loop_info64
loinfo
;
struct
loop_info64
loinfo
;
int
ret
=
-
1
,
fd
=
-
1
,
rc
;
int
ret
=
-
1
,
fd
=
-
1
,
rc
;
DIR
*
dir
;
DIR
*
dir
;
...
@@ -602,8 +602,7 @@ static int mount_rootfs_file(const char *rootfs, const char *target,
...
@@ -602,8 +602,7 @@ static int mount_rootfs_file(const char *rootfs, const char *target,
return
-
1
;
return
-
1
;
}
}
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
((
direntp
=
readdir
(
dir
)))
{
if
(
!
direntp
)
if
(
!
direntp
)
break
;
break
;
...
@@ -2938,7 +2937,7 @@ void lxc_restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf)
...
@@ -2938,7 +2937,7 @@ void lxc_restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf)
{
{
int
i
,
ret
,
oldfd
;
int
i
,
ret
,
oldfd
;
char
path
[
MAXPATHLEN
];
char
path
[
MAXPATHLEN
];
char
ifname
[
IFNAMSIZ
];
char
ifname
[
IFNAMSIZ
];
if
(
netnsfd
<
0
||
conf
->
num_savednics
==
0
)
if
(
netnsfd
<
0
||
conf
->
num_savednics
==
0
)
return
;
return
;
...
...
src/lxc/confile.c
View file @
4e57e9dc
...
@@ -1007,7 +1007,7 @@ static int config_hook(const char *key, const char *value,
...
@@ -1007,7 +1007,7 @@ static int config_hook(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
struct
lxc_conf
*
lxc_conf
)
{
{
char
*
copy
;
char
*
copy
;
if
(
!
value
||
strlen
(
value
)
==
0
)
if
(
!
value
||
strlen
(
value
)
==
0
)
return
lxc_clear_hooks
(
lxc_conf
,
key
);
return
lxc_clear_hooks
(
lxc_conf
,
key
);
...
...
src/lxc/lxccontainer.c
View file @
4e57e9dc
...
@@ -509,7 +509,7 @@ static bool wait_on_daemonized_start(struct lxc_container *c, int pid)
...
@@ -509,7 +509,7 @@ static bool wait_on_daemonized_start(struct lxc_container *c, int pid)
static
bool
am_single_threaded
(
void
)
static
bool
am_single_threaded
(
void
)
{
{
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
DIR
*
dir
;
DIR
*
dir
;
int
count
=
0
;
int
count
=
0
;
...
@@ -519,7 +519,7 @@ static bool am_single_threaded(void)
...
@@ -519,7 +519,7 @@ static bool am_single_threaded(void)
return
false
;
return
false
;
}
}
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
(
(
direntp
=
readdir
(
dir
)
))
{
if
(
!
direntp
)
if
(
!
direntp
)
break
;
break
;
...
@@ -2988,7 +2988,7 @@ static int lxcapi_snapshot_list(struct lxc_container *c, struct lxc_snapshot **r
...
@@ -2988,7 +2988,7 @@ static int lxcapi_snapshot_list(struct lxc_container *c, struct lxc_snapshot **r
{
{
char
snappath
[
MAXPATHLEN
],
path2
[
MAXPATHLEN
];
char
snappath
[
MAXPATHLEN
],
path2
[
MAXPATHLEN
];
int
dirlen
,
count
=
0
,
ret
;
int
dirlen
,
count
=
0
,
ret
;
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
struct
lxc_snapshot
*
snaps
=
NULL
,
*
nsnaps
;
struct
lxc_snapshot
*
snaps
=
NULL
,
*
nsnaps
;
DIR
*
dir
;
DIR
*
dir
;
...
@@ -3007,7 +3007,7 @@ static int lxcapi_snapshot_list(struct lxc_container *c, struct lxc_snapshot **r
...
@@ -3007,7 +3007,7 @@ static int lxcapi_snapshot_list(struct lxc_container *c, struct lxc_snapshot **r
return
0
;
return
0
;
}
}
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
(
(
direntp
=
readdir
(
dir
)
))
{
if
(
!
direntp
)
if
(
!
direntp
)
break
;
break
;
...
@@ -3439,7 +3439,7 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta
...
@@ -3439,7 +3439,7 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta
{
{
DIR
*
dir
;
DIR
*
dir
;
int
i
,
cfound
=
0
,
nfound
=
0
;
int
i
,
cfound
=
0
,
nfound
=
0
;
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
if
(
!
lxcpath
)
if
(
!
lxcpath
)
...
@@ -3456,7 +3456,7 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta
...
@@ -3456,7 +3456,7 @@ int list_defined_containers(const char *lxcpath, char ***names, struct lxc_conta
if
(
names
)
if
(
names
)
*
names
=
NULL
;
*
names
=
NULL
;
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
(
(
direntp
=
readdir
(
dir
)
))
{
if
(
!
direntp
)
if
(
!
direntp
)
break
;
break
;
...
...
src/lxc/start.c
View file @
4e57e9dc
...
@@ -188,7 +188,7 @@ static int match_fd(int fd)
...
@@ -188,7 +188,7 @@ static int match_fd(int fd)
int
lxc_check_inherited
(
struct
lxc_conf
*
conf
,
int
fd_to_ignore
)
int
lxc_check_inherited
(
struct
lxc_conf
*
conf
,
int
fd_to_ignore
)
{
{
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
int
fd
,
fddir
;
int
fd
,
fddir
;
DIR
*
dir
;
DIR
*
dir
;
...
@@ -201,7 +201,7 @@ restart:
...
@@ -201,7 +201,7 @@ restart:
fddir
=
dirfd
(
dir
);
fddir
=
dirfd
(
dir
);
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
(
(
direntp
=
readdir
(
dir
)
))
{
if
(
!
direntp
)
if
(
!
direntp
)
break
;
break
;
...
...
src/lxc/utils.c
View file @
4e57e9dc
...
@@ -62,7 +62,7 @@ extern bool btrfs_try_remove_subvol(const char *path);
...
@@ -62,7 +62,7 @@ extern bool btrfs_try_remove_subvol(const char *path);
static
int
_recursive_rmdir
(
char
*
dirname
,
dev_t
pdev
,
bool
onedev
)
static
int
_recursive_rmdir
(
char
*
dirname
,
dev_t
pdev
,
bool
onedev
)
{
{
struct
dirent
dirent
,
*
direntp
;
struct
dirent
*
direntp
;
DIR
*
dir
;
DIR
*
dir
;
int
ret
,
failed
=
0
;
int
ret
,
failed
=
0
;
char
pathname
[
MAXPATHLEN
];
char
pathname
[
MAXPATHLEN
];
...
@@ -73,7 +73,7 @@ static int _recursive_rmdir(char *dirname, dev_t pdev, bool onedev)
...
@@ -73,7 +73,7 @@ static int _recursive_rmdir(char *dirname, dev_t pdev, bool onedev)
return
-
1
;
return
-
1
;
}
}
while
(
!
readdir_r
(
dir
,
&
dirent
,
&
direntp
))
{
while
(
(
direntp
=
readdir
(
dir
)
))
{
struct
stat
mystat
;
struct
stat
mystat
;
int
rc
;
int
rc
;
...
...
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