Date: Sat, 18 Apr 2015 23:34:21 +0800 From: freekai <freekai@outlook.com> To: <freebsd-jail@freebsd.org> Subject: Create Jail fail by c language Message-ID: <BLU403-EAS181EC3EE31BC31CDFE53C3AABE20@phx.gbl>
next in thread | raw e-mail | index | archive | help
This is My Code: 1 #include<sys/param.h> 2 #include<sys/jail.h> 3 #include<arpa/inet.h> 4 #include<stdio.h> 5 #include<errno.h> 6=20 7 int main() 8 { 9 int jid; 10 struct jail j; 11 struct in_addr ip4; 12 const char *cp=3D"192.168.1.10"; 13=20 14 j.version=3DJAIL_API_VERSION; 15 j.path=3D"/home/mk/jail"; 16 j.hostname=3D"testJail"; 17 j.jailname=3D"test"; 18 j.ip4s=3Dinet_addr(cp); 19 j.ip6s=3D0; 20=20 21 if(1!=3Dinet_aton(cp,&ip4)) 22 printf("the address is invalid\r\n"); 23=20 24 j.ip4=3D&ip4; 25 j.ip6=3DNULL; 26=20 27 jid=3Djail(&j); 28=20 29 switch(errno){ 30 case EPERM: 31 printf("eperm\r\n"); 32 break; 33 case EFAULT: 34 printf("efault\r\n"); 35 break; 36 case EINVAL: 37 printf("einval\r\n"); 38 break; 39=20 40 case EAGAIN: 41 printf("eagain\r\n"); 42 } 47 return 0; 48 } The problem is it will print `einval`,it means `The version number of = the argument is not correct.` How to solve it?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BLU403-EAS181EC3EE31BC31CDFE53C3AABE20>