~ubuntu-branches/ubuntu/maverick/eucalyptus/maverick

« back to all changes in this revision

Viewing changes to clc/modules/storage-controller/native/edu_ucsb_eucalyptus_storage_LVM2Manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Dave Walker (Daviey)
  • Date: 2010-07-21 17:27:10 UTC
  • mfrom: (1.1.38 upstream)
  • Revision ID: james.westby@ubuntu.com-20100721172710-7xv07dmdqgivc3t9
Tags: 2.0~bzr1211-0ubuntu1
* New major upstream version merge, 2.0 (r1211).
* debian/patches/:
  - 01-wsdl-stubs.patch, debian/wsdl.md5sums: wsdl stubs updated.
  - 02-Makefile.patch: Updated to reflect new code layout.
  - 07-local_support_euca_conf-in.patch: Updated to reflect new code layout.
  - 08-ubuntu-default-networking.patch: Refreshed.
  - 09-small-128-192MB.patch: Updated to point to new location.
  - 10-disable-iscsi.patch: Refreshed.
  - 11-state-cleanup-memleakfix.patch: Removed, fixed upstream.
  - 15-fix-default-ramdisk.patch: Updated to point to new location.
  - 16-kvm_libvirt_xml_default_use_kvm.patch: Updated to reflect changes.
  - 17-fix_walrus_OOM_errors.patch: Removed, fixed upstream.
  - 18-priv_security.patch: Updated to reflect upstream changes.
  - 20-brute-force-webui.patch: Updated to reflect upstream changes. 
  - 21-eucalyptus-1.7-with-gwt-1.6.4.patch: New patch, allows 
    eucalyptus-1.7 to be built against gwt 1.6.4. Based on patch courtesy 
    of Dmitrii Zagorodnov, upstream. (LP: #597330)
* debian/eucalyptus-java-common.links: 
  - Changed symlink for groovy, point to groovy.all.jar, making compatiable 
    with groovy versions >1.7. (LP: #595421)
  - Added ant.jar & jetty-rewrite-handler.jar as they are now required.
* debian/control
  - & debian/build-jars: Added libjavassist-java and libjetty-extra-java as 
    build dependencies.
  - Added libjetty-extra-java as a dependency of eucalyptus-java-common
* The binary resulting jar's have been renamed from eucalyptus-*-1.6.2.jar
  to eucalyptus-*-main.jar:    
  - debian/eucalyptus-cc.upstart
  - debian/eucalyptus-cloud.install
  - debian/eucalyptus-common.eucalyptus.upstart
  - debian/eucalyptus-java-common.install
  - debian/eucalyptus-network.upstart
  - debian/eucalyptus-sc.install
  - debian/eucalyptus-walrus.install
* debian/eucalyptus-java-common.install: New upstream jars that have been
  installed:
  - eucalyptus-db-hsqldb-ext-main.jar
  - eucalyptus-component-main.jar
* debian/control:
  - Updated Standards Version to 3.8.4 (no change)
  - Updated the upstream Homepage to: http://open.eucalyptus.com/
  - Changed Vcs-Bzr to reflect new location of Ubuntu hosted development branch.
  - Made the Build Dependency of groovy and the binary eucalyptus-java-common
    package depend on version >=1.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Author: Sunil Soman sunils@cs.ucsb.edu
3
 
 */
4
 
 
5
 
#include <edu_ucsb_eucalyptus_storage_LVM2Manager.h>
6
 
#include <unistd.h>
7
 
#include <string.h>
8
 
#include <stdlib.h>
9
 
#include <sys/types.h>
10
 
#include <dirent.h>
11
 
#include <sys/wait.h>
12
 
#include <signal.h>
13
 
 
14
 
#define EUCALYPTUS_ENV_VAR_NAME  "EUCALYPTUS"
15
 
 
16
 
static const char* blockSize = "1M";
17
 
 
18
 
int run_command_and_get_pid(char *cmd, char **args) {
19
 
        int pid = -1;
20
 
        int fds_to_close[1024];
21
 
        int curr_fd = 0;
22
 
 
23
 
        if ((pid = fork()) == -1) {
24
 
                perror("Could not run command");
25
 
                return -1;
26
 
        }
27
 
 
28
 
        if (pid == 0) {
29
 
                //daemonize
30
 
                DIR *proc_fd_dir;
31
 
                struct dirent *fd_dir;
32
 
                int fd_to_close;
33
 
                char fd_path[128];
34
 
                int my_pid = getpid();
35
 
 
36
 
                umask(0);
37
 
                int sid = setsid();
38
 
                if(sid < 0)
39
 
                        exit(-1);
40
 
                char* home = getenv (EUCALYPTUS_ENV_VAR_NAME);
41
 
                if (!home) {
42
 
                        home = strdup (""); /* root by default */
43
 
                } else {
44
 
                        home = strdup (home);
45
 
                }
46
 
                fprintf(stderr, "command: %s\n", cmd);
47
 
                chdir(home);
48
 
 
49
 
                //close all open fds
50
 
                snprintf(fd_path, 128, "/proc/%d/fd", my_pid);
51
 
 
52
 
                if ((proc_fd_dir = opendir(fd_path)) != NULL) {
53
 
                        curr_fd = 0;
54
 
                        while ((fd_dir = readdir(proc_fd_dir)) != NULL) {
55
 
                                if (isdigit(fd_dir->d_name[0])) {
56
 
                                        fds_to_close[curr_fd++] =  atoi(fd_dir->d_name);
57
 
                                }
58
 
                        }
59
 
                        int i = 0;
60
 
                        for(i=0 ; i < curr_fd; ++i) {
61
 
                                close(fds_to_close[i]);
62
 
                        }
63
 
                } else {
64
 
                        int i = 0;
65
 
                        for(i=0 ; i < 1024; ++i) {
66
 
                                close(i);
67
 
                        }
68
 
                }
69
 
 
70
 
                freopen( "/dev/null", "r", stdin);
71
 
                freopen( "/dev/null", "w", stdout);
72
 
                freopen( "/dev/null", "w", stderr);
73
 
                exit(execvp(cmd, args));
74
 
        }
75
 
        return pid;
76
 
}
77
 
 
78
 
void sigchld(int signal)
79
 
{
80
 
        while (0 < waitpid(-1, NULL, WNOHANG));
81
 
}
82
 
 
83
 
JNIEXPORT void JNICALL Java_edu_ucsb_eucalyptus_storage_LVM2Manager_registerSignals
84
 
(JNIEnv *env, jobject obj) {
85
 
        signal(SIGCHLD, sigchld);
86
 
}
87