namespace: use is_symlink() helper
We have this prett ylittle helper, let's use it, it makes things a tiny bit more readable.
This commit is contained in:
parent
6f7f3a3351
commit
36ce7110b0
|
@ -42,6 +42,7 @@
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
#include "selinux-util.h"
|
#include "selinux-util.h"
|
||||||
#include "socket-util.h"
|
#include "socket-util.h"
|
||||||
|
#include "stat-util.h"
|
||||||
#include "string-table.h"
|
#include "string-table.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
|
@ -537,7 +538,6 @@ static int mount_private_dev(MountEntry *m) {
|
||||||
char temporary_mount[] = "/tmp/namespace-dev-XXXXXX";
|
char temporary_mount[] = "/tmp/namespace-dev-XXXXXX";
|
||||||
const char *d, *dev = NULL, *devpts = NULL, *devshm = NULL, *devhugepages = NULL, *devmqueue = NULL, *devlog = NULL, *devptmx = NULL;
|
const char *d, *dev = NULL, *devpts = NULL, *devshm = NULL, *devhugepages = NULL, *devmqueue = NULL, *devlog = NULL, *devptmx = NULL;
|
||||||
_cleanup_umask_ mode_t u;
|
_cleanup_umask_ mode_t u;
|
||||||
struct stat st;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
|
@ -567,11 +567,10 @@ static int mount_private_dev(MountEntry *m) {
|
||||||
*
|
*
|
||||||
* in nspawn and other containers it will be a symlink, in that case make it a symlink
|
* in nspawn and other containers it will be a symlink, in that case make it a symlink
|
||||||
*/
|
*/
|
||||||
if (lstat("/dev/ptmx", &st) < 0) {
|
r = is_symlink("/dev/ptmx");
|
||||||
r = -errno;
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
if (r > 0) {
|
||||||
if (S_ISLNK(st.st_mode)) {
|
|
||||||
devptmx = strjoina(temporary_mount, "/dev/ptmx");
|
devptmx = strjoina(temporary_mount, "/dev/ptmx");
|
||||||
if (symlink("pts/ptmx", devptmx) < 0) {
|
if (symlink("pts/ptmx", devptmx) < 0) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
|
|
Loading…
Reference in a new issue