Headers cleanup

This commit is contained in:
dlezcano 2008-09-04 09:46:22 +00:00
parent f291d61b3f
commit 06efeb5c0e
7 changed files with 19 additions and 46 deletions

View File

@ -27,12 +27,8 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/inotify.h>
#include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h>
#include <net/if.h>
#include <lxc.h> #include <lxc.h>

View File

@ -21,9 +21,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define _GNU_SOURCE
#include <stdio.h>
#undef _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -31,12 +28,9 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/inotify.h>
#include <sys/file.h>
#include <netinet/in.h>
#include <net/if.h>
#include <lxc.h> #include <lxc.h>
#include "monitor.h"
static int dir_filter(const struct dirent *dirent) static int dir_filter(const struct dirent *dirent)
{ {

View File

@ -30,14 +30,11 @@
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <netinet/in.h>
#include <net/if.h>
#include <lxc.h> #include <lxc.h>

View File

@ -29,34 +29,30 @@
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/inotify.h>
#include <netinet/in.h>
#include <net/if.h>
#include <lxc.h> #include <lxc.h>
static int freeze_unfreeze(const char *name, int freeze) static int freeze_unfreeze(const char *name, int freeze)
{ {
char *freezer, *f = freeze?"FROZEN":"RUNNING"; char freezer[MAXPATHLEN], *f = freeze?"FROZEN":"RUNNING";
int fd, ret = -1; int fd, ret = -1;
asprintf(&freezer, LXCPATH "/%s/nsgroup/freezer.state", name); snprintf(freezer, MAXPATHLEN,
LXCPATH "/%s/nsgroup/freezer.state", name);
fd = open(freezer, O_WRONLY); fd = open(freezer, O_WRONLY);
if (fd < 0) { if (fd < 0) {
lxc_log_syserror("failed to open freezer for '%s'", name); lxc_log_syserror("failed to open freezer for '%s'", name);
goto out; return -1;
} }
ret = write(fd, f, strlen(f) + 1) < 0; ret = write(fd, f, strlen(f) + 1) < 0;
close(fd); close(fd);
if (ret) if (ret)
lxc_log_syserror("failed to write to '%s'", freezer); lxc_log_syserror("failed to write to '%s'", freezer);
out:
free(freezer); return 0;
return ret;
} }
int lxc_freeze(const char *name) int lxc_freeze(const char *name)

View File

@ -29,26 +29,26 @@
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h> #include <sys/param.h>
#include <netinet/in.h>
#include <net/if.h>
#include <lxc.h> #include <lxc.h>
int lxc_kill(const char *name, int signum) int lxc_kill(const char *name, int signum)
{ {
char *freezer = NULL, *signal = NULL; char freezer[MAXPATHLEN], *signal = NULL;
int fd = -1, ret = -1; int fd = -1, ret = -1;
if (signum < SIGHUP || signum > SIGRTMAX) { if (signum < SIGHUP || signum > SIGRTMAX) {
lxc_log_error("bad signal value %d", signum); lxc_log_error("bad signal value %d", signum);
goto out; return -1;
} }
asprintf(&freezer, LXCPATH "/%s/nsgroup/freezer.kill", name); snprintf(freezer, MAXPATHLEN, LXCPATH "/%s/nsgroup/freezer.kill", name);
asprintf(&signal, "%d", signum);
if (!asprintf(&signal, "%d", signum)) {
lxc_log_syserror("not enough memory");
return -1;
}
fd = open(freezer, O_WRONLY); fd = open(freezer, O_WRONLY);
if (fd < 0) { if (fd < 0) {
@ -64,7 +64,6 @@ int lxc_kill(const char *name, int signum)
ret = 0; ret = 0;
out: out:
close(fd); close(fd);
free(freezer);
free(signal); free(signal);
return ret; return ret;
} }

View File

@ -30,15 +30,11 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <mntent.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <netinet/in.h>
#include <net/if.h>
#include <lxc.h> #include <lxc.h>

View File

@ -20,21 +20,16 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#undef _GNU_SOURCE
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <errno.h> #include <errno.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/param.h> #include <fcntl.h>
#include <sys/file.h>
#include <netinet/in.h>
#include <net/if.h>
#include <lxc.h> #include <lxc.h>