lxc-start 源码分析

Posted by 夏泽民

https://github.com/lxc/lxc lxc_start.c int main(int argc, char *argv[]) { int err = 1; struct lxc_conf *conf; //初始化config结构 char *const *args; //传递的参数 char *rcfile = NULL; //指定配置文件 char *const default_args[] = { //默认的args参数 “/sbin/init”, NULL, };
struct lxc_container *c; //lxc-container 的结构体 …. } lxc_conf这个数据结构 struct lxc_conf { int is_execute; //容器是否在执行 char *fstab; //fstab? int tty; //tty的个数 int pts; //pts的个数? int reboot; //重启? int need_utmp_watch; //字面翻译 需要utmp 查看 signed long personality; //字面翻译 特点 struct utsname *utsname; //ustname struct lxc_list cgroup; //cgroup list lxc_list只是简单的链表结构 struct lxc_list id_map; //id_map list struct lxc_list network; //network list struct saved_nic *saved_nics;//saved_nics 结构 int num_savednics; //savednics数量? int auto_mounts; //auto_mounts? struct lxc_list mount_list; //mount_list list? struct lxc_list caps; //caps list? struct lxc_list keepcaps; //keepcaps list? struct lxc_tty_info tty_info; //tty的相关信息 struct lxc_console console; //console的结构体 struct lxc_rootfs rootfs; //rootfs的结构体 char *ttydir; //tty目录 int close_all_fds; //关闭所有fd struct lxc_list hooks[NUM_LXC_HOOKS]; //hooks 函数

char *lsm_aa_profile;   //?
char *lsm_se_context;	//?
int tmp_umount_proc;	//?
char *seccomp;  // filename with the seccomp rules #if HAVE_SCMP_FILTER_CTX
scmp_filter_ctx seccomp_ctx; #endif
int maincmd_fd;		//?
int autodev;  // if 1, mount and fill a /dev at start
int haltsignal; // signal used to halt container
int stopsignal; // signal used to hard stop container
int kmsg;  // if 1, create /dev/kmsg symlink
char *rcfile;   // Copy of the top level rcfile we read
 
// Logfile and loglevel can be set in a container config file.
// Those function as defaults.  The defaults can be overriden
// by command line.  However we don't want the command line
// specified values to be saved on c->save_config().  So we
// store the config file specified values here.
char *logfile;  // the logfile as specifed in config
int loglevel;   // loglevel as specifed in config (if any)
 
int inherit_ns_fd[LXC_NS_MAX];
 
int start_auto;
int start_delay;
int start_order;
struct lxc_list groups;
int nbd_idx;
 
/* set to true when rootfs has been setup */
bool rootfs_setup; };


hijack

Posted by 夏泽民

type Hijacker interface { Hijack() (net.Conn, *bufio.ReadWriter, error) } //返回连接接口net.Conn和ReadWriter,bufio读写的 // Hijack lets the caller take over the connection. —–Hijack让调用者管理连接



gotty 把你的 Linux 终端放到浏览器里面

Posted by 夏泽民

https://github.com/yudai/gotty GoTTY 是一个简单的基于 Go 语言的命令行工具,它可以将你的终端(TTY)作为 web 程序共享。它会将命令行工具转换为 web 程序。



fcgi

Posted by 夏泽民

nginx 配置 server { listen 80; server_name go.dev; root /root/go/src/godev; index index.html; #gzip off; #proxy_buffering off;



fastcgi_client

Posted by 夏泽民

CGI全称是“通用网关接口”(Common Gateway Interface),HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序一般运行在网络服务器上。 CGI可以用任何一种语言编写,只要这种语言具有标准输入、输出和环境变量。如php,perl,tcl等。



Search

Popular posts

Anything in here will be replaced on browsers that support the canvas element

Recent posts

This blog is maintained by 夏泽民

Get in touch with me at 465474307@qq.com

Subscribe to our mailing list

* indicates required