~ubuntu-branches/ubuntu/karmic/vzctl/karmic

« back to all changes in this revision

Viewing changes to src/lib/fs_simfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2007-04-10 18:08:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070410180816-0uuzj9fnna7gmzxv
Tags: 3.0.16-4
Etch has been released which means that this version can be uploaded
to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2000-2006 SWsoft. All rights reserved.
 
2
 *  Copyright (C) 2000-2007 SWsoft. All rights reserved.
3
3
 *
4
4
 *  This program is free software; you can redistribute it and/or modify
5
5
 *  it under the terms of the GNU General Public License as published by
39
39
        FILE *fp;
40
40
        char buf[512];
41
41
        char mnt[512];
42
 
        int ret = 0; 
 
42
        char *path;
 
43
        int ret = 0;
43
44
 
44
45
        if ((fp = fopen("/proc/mounts", "r")) == NULL) {
45
 
                logger(0, errno,  "unable to open /proc/mounts");
 
46
                logger(-1, errno,  "unable to open /proc/mounts");
46
47
                return -1;
47
48
        }
 
49
        path = realpath(root, NULL);
 
50
        if (path == NULL)
 
51
                path = strdup(root);
48
52
        while (!feof(fp)) {
49
53
                if (fgets(buf, sizeof(buf), fp) == NULL)
50
54
                        break;
51
55
                if (sscanf(buf, "%*[^ ] %s ", mnt) != 1)
52
56
                        continue;
53
 
                if (!strcmp(mnt, root)) {
 
57
                if (!strcmp(mnt, path)) {
54
58
                        ret = 1;        
55
59
                        break;
56
60
                }
57
61
        }
 
62
        free(path);
58
63
        fclose(fp);
59
64
        return ret;
60
65
}
69
74
{
70
75
        int mntopt = 0;
71
76
 
72
 
        if (fs->noatime == YES)
73
 
                mntopt |= MS_NOATIME;
74
 
        if (remount)
 
77
        if (fs->noatime == YES)
 
78
                mntopt |= MS_NOATIME;
 
79
        if (remount)
75
80
                mntopt |= MS_REMOUNT;
76
 
        logger(2, 0,  "Mounting root: %s %s", fs->root, fs->private);
77
 
        if (mount(fs->private, fs->root, "simfs", mntopt,
 
81
        logger(2, 0,  "Mounting root: %s %s", fs->root, fs->private);
 
82
        if (mount(fs->private, fs->root, "simfs", mntopt,
78
83
                        remount ? "" : fs->private) < 0)
79
84
        {
80
 
                logger(0, errno, "Can't mount: %s %s", fs->root, fs->private);
81
 
                return VZ_FS_CANTMOUNT;
82
 
        }
 
85
                logger(-1, errno, "Can't mount: %s %s", fs->root, fs->private);
 
86
                if (errno == ENODEV)
 
87
                        logger(-1, errno, "Kernel lacks simfs support. Please "
 
88
                                "compile it in, or load simfs module.");
 
89
                return VZ_FS_CANTMOUNT;
 
90
        }
83
91
        return 0;
84
92
}