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

« back to all changes in this revision

Viewing changes to src/lxc/state.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:
55
55
        for (i = 0; i < len; i++)
56
56
                if (!strcmp(strstate[i], state))
57
57
                        return i;
 
58
 
 
59
        ERROR("invalid state '%s'", state);
58
60
        return -1;
59
61
}
60
62
 
61
63
int lxc_setstate(const char *name, lxc_state_t state)
62
64
{
63
 
        int fd, err;
 
65
        int fd, err = -1;
64
66
        char file[MAXPATHLEN];
65
67
        const char *str = lxc_state2str(state);
66
68
 
67
69
        if (!str)
68
 
                return -1;
 
70
                return err;
69
71
 
70
72
        snprintf(file, MAXPATHLEN, LXCPATH "/%s/state", name);
71
73
 
72
74
        fd = open(file, O_WRONLY);
73
75
        if (fd < 0) {
74
76
                SYSERROR("failed to open %s file", file);
75
 
                return -1;
 
77
                return err;
76
78
        }
77
79
 
78
80
        if (flock(fd, LOCK_EX)) {
91
93
        }
92
94
 
93
95
        err = 0;
 
96
 
 
97
        DEBUG("set state to '%s'", str);
94
98
out:
95
99
        close(fd);
96
100
 
97
101
        lxc_monitor_send_state(name, state);
98
102
 
99
 
        return -err;
 
103
        return err;
100
104
}
101
105
 
102
106
int lxc_mkstate(const char *name)