Revision: 427 http://vde.svn.sourceforge.net/vde/?rev=427&view=rev Author: shammash Date: 2010-07-03 18:18:23 +0000 (Sat, 03 Jul 2010)
Log Message: ----------- vde_switch: early ctl socket dir creation Move ctl socket dir creation at parsing time to let vde_realpath() do its resolution. This fixes problems like vde_switch creating /tmp/switch/ctl instead of /tmp/switch/data/ctl in the following scenario: $ rm -rf /tmp/switch $ vde_switch -s /tmp/switch/data Signed-off-by: Luca Bigliardi <shamm...@artha.org> Modified Paths: -------------- trunk/vde-2/src/vde_switch/datasock.c Modified: trunk/vde-2/src/vde_switch/datasock.c =================================================================== --- trunk/vde-2/src/vde_switch/datasock.c 2010-07-03 16:28:00 UTC (rev 426) +++ trunk/vde-2/src/vde_switch/datasock.c 2010-07-03 18:18:23 UTC (rev 427) @@ -363,9 +363,17 @@ struct group *grp; switch (c) { case 's': - /* This should return NULL as the path probably does not exist */ - vde_realpath(optarg, real_ctl_socket); - ctl_socket = real_ctl_socket; + if (((mkdir(optarg, 0777) < 0) && (errno != EEXIST))) { + fprintf(stderr,"Cannot create ctl directory '%s': %s\n", + optarg, strerror(errno)); + exit(1); + } + ctl_socket = vde_realpath(optarg, real_ctl_socket); + if (!ctl_socket) { + fprintf(stderr,"Cannot resolve ctl dir path '%s': %s\n", + optarg, strerror(errno)); + exit(1); + } break; case 'm': sscanf(optarg,"%o",&mode); @@ -431,10 +439,8 @@ printlog(LOG_ERR,"Could not set O_NONBLOCK on connection fd %d: %s", connect_fd, strerror(errno)); return; } - if (((mkdir(ctl_socket, 0777) < 0) && (errno != EEXIST))){ - printlog(LOG_ERR,"Could not create the VDE ctl directory '%s': %s", ctl_socket, strerror(errno)); - exit(-1); - } + /* ctl_socket dir is created while parsing to provide an existing path + * to vde_realpath() */ if(chown(ctl_socket,-1,grp_owner) < 0) { rmdir(ctl_socket); printlog(LOG_ERR, "Could not chown socket '%s': %s", sun.sun_path, strerror(errno)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ vde-users mailing list vde-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vde-users