criu/mount.c
Cyrill Gorcunov ed59bf001b Add mount.c file for mount helpers functions
At moment only open_mnt_root is there, which is
needed for inotify restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 14:00:36 +04:00

42 lines
752 B
C

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include <string.h>
#include "types.h"
#include "util.h"
#include "mount.h"
#include "proc_parse.h"
/*
* Returns path for mount device @s_dev
*
* FIXME this is not sufficient in general
* since mount points can be overmounted but
* works for now.
*/
int open_mnt_root(unsigned int s_dev, struct proc_mountinfo *mntinfo, int nr_mntinfo)
{
static int last = 0;
int i;
again:
for (i = last; i < nr_mntinfo; i++) {
if (s_dev == mntinfo[i].s_dev) {
last = i;
return open(mntinfo[i].mnt_root, O_RDONLY);
}
}
if (last) {
last = 0;
goto again;
}
return -ENOENT;
}