Commit ed59bf00 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9ea069d2
...@@ -53,6 +53,7 @@ OBJS += netfilter.o ...@@ -53,6 +53,7 @@ OBJS += netfilter.o
OBJS += shmem.o OBJS += shmem.o
OBJS += eventfd.o OBJS += eventfd.o
OBJS += eventpoll.o OBJS += eventpoll.o
OBJS += mount.o
DEPS := $(patsubst %.o,%.d,$(OBJS)) DEPS := $(patsubst %.o,%.d,$(OBJS))
......
#ifndef MOUNT_H__
#define MOUNT_H__
struct proc_mountinfo;
extern int open_mnt_root(unsigned int s_dev, struct proc_mountinfo *mntinfo, int nr_mntinfo);
#endif /* MOUNT_H__ */
#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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment