X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fvbuild.cc;h=9dd6ac4601bdd3eb0f03830785332e7b31c1412b;hb=780710c3d80b8776944dd1fc65a0fda64f399db0;hp=ed278097217cbe55a8773e5080c4c8a3f310f7de;hpb=8cf13bb177d92c93eb73dc8939777150536c2d00;p=util-vserver.git diff --git a/src/vbuild.cc b/src/vbuild.cc index ed27809..9dd6ac4 100644 --- a/src/vbuild.cc +++ b/src/vbuild.cc @@ -1,4 +1,4 @@ -// $Id: vbuild.cc,v 1.1.4.1 2004/02/09 22:55:00 ensc Exp $ +// $Id: vbuild.cc,v 1.4 2003/10/21 13:55:35 ensc Exp $ // Copyright (C) 2003 Enrico Scholz // based on vbuild.cc by Jacques Gelinas @@ -22,6 +22,10 @@ It uses hard link whenever possible instead of duplicating files. Once done, it sets the immutable bits. */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include @@ -34,6 +38,8 @@ #include #include #include +#include + #include "vutil.h" using namespace std; @@ -211,6 +217,12 @@ static int vbuild_copy ( return ret; } +static void +prepareVserver(Vserver const UNUSED &src, char const UNUSED *dst) +{ + assert(false); +} + int main (int argc, char *argv[]) { int ret = -1; @@ -241,32 +253,32 @@ int main (int argc, char *argv[]) if (i!=argc-2){ usage(); }else{ - string refserv = argv[i++]; - string newserv = argv[i]; - list packages; + Vserver refserv(argv[i++]); + + prepareVserver(refserv, argv[i]); + Vserver newserv(argv[i]); + list packages; // Load the files which are not configuration files from // the packages vutil_loadallpkg (refserv,packages); set files; - for (list::iterator it=packages.begin(); it!=packages.end(); it++){ + for (list::iterator it=packages.begin(); it!=packages.end(); it++){ (*it).loadfiles(refserv,files); } // Now, we do a recursive copy of refserv into newserv umask (0); - mkdir (newserv.c_str(),0755); - setext2flag(newserv.c_str(), false, 0); // Check if it is on the same volume struct stat refst,newst; - if (vutil_lstat(refserv,refst)!=-1 - && vutil_lstat(newserv,newst)!=1){ + if (vutil_lstat(refserv.getName().c_str(),refst)!=-1 + && vutil_lstat(newserv.getName().c_str(),newst)!=1){ if (refst.st_dev != newst.st_dev){ - fprintf (stderr,"Can't vbuild %s because it is not on the same volume as %s\n" - ,newserv.c_str(),refserv.c_str()); + fprintf (stderr,"Can't vbuild %s because it is not on the same volume as %s\n", + newserv.getName().c_str(),refserv.getName().c_str()); }else{ stats.nbdir = stats.nblink = stats.nbcopy = stats.nbsymlink = 0; stats.nbspc = 0; stats.size_copy = 0; - ret = vbuild_copy (refserv,newserv,refst.st_dev,"",files); + ret = vbuild_copy (refserv.getName(),newserv.getName(),refst.st_dev,"",files); if (statistics){ printf ("Directory created: %d\n",stats.nbdir); printf ("Files copied : %d\n",stats.nbcopy);