~serge-hallyn/ubuntu/natty/lxc/lxc-fix-3bugs

« back to all changes in this revision

Viewing changes to src/lxc/create.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2009-07-25 12:24:30 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090725122430-dxv1wb7ds07fc0sk
Tags: 0.6.3-1
* New Upstream Version
* Remove duplicate build-dependency on autotools-dev
* Build depend on linux-libc-dev
* Disable checking of netlink headers from configure
  (currently fails under sid)
* Upgrade standards-version to 3.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
 
62
62
        if (mkdir(LXCPATH, 0755) && errno != EEXIST) {
63
63
                SYSERROR("failed to create %s directory", LXCPATH);
64
 
                return -errno;
 
64
                return -1;
65
65
        }
66
66
 
67
 
        sprintf(path, LXCPATH "/%s", dirname);
 
67
        snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
68
68
 
69
69
        if (mkdir(path, 0755)) {
70
70
                SYSERROR("failed to create %s directory", path);
71
 
                return -errno;
 
71
                return -1;
72
72
        }
73
73
 
74
74
        return 0;
78
78
{
79
79
        char path[MAXPATHLEN];
80
80
 
81
 
        sprintf(path, LXCPATH "/%s", dirname);
 
81
        snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
82
82
 
83
83
        if (rmdir(path)) {
84
84
                SYSERROR("failed to remove %s directory", path);
97
97
 
98
98
int lxc_create(const char *name, struct lxc_conf *conf)
99
99
{
100
 
        int lock, err;
 
100
        int lock, err = -1;
101
101
 
102
 
        err = create_lxc_directory(name);
103
 
        if (err < 0)
104
 
                return err == -EEXIST ?
105
 
                        -LXC_ERROR_EEXIST : LXC_ERROR_INTERNAL;
 
102
        if (create_lxc_directory(name))
 
103
                return err;
106
104
        
107
105
        lock = lxc_get_lock(name);
108
106
        if (lock < 0)
109
 
                return -LXC_ERROR_LOCK;
 
107
                return err;
110
108
 
111
 
        err = LXC_ERROR_INTERNAL;
112
109
        if (lxc_mkstate(name)) {
113
110
                ERROR("failed to create the state file for %s", name);
114
111
                goto err;
119
116
                goto err_state;
120
117
        }
121
118
 
122
 
        err = lxc_configure(name, conf);
123
 
        if (err) {
 
119
        if (lxc_configure(name, conf)) {
124
120
                ERROR("failed to set configuration for %s", name);
125
121
                goto err_state;
126
122
        }