rsync ported to BeOS-bone

François Revol revol at free.fr
Sat Feb 22 03:08:22 EST 2003


Hello, here is a preliminary patch allowing rsync 2.5.6
to compile in BeOS (using the new BONE networking stack).

Some explanations:
- BeOS doesn't have chroot(),
- the BONE networking stack export legacy network function
for old apps in libnet.so (linked to by default), so it's 
necessary to force linking to the new libraries for things 
to work. I've yet to get inet_ntop() to be used from 
libbind.so... but I'm not qualified enough on autoconf.
- the openlog() and syslog() functions are exported by 
libbe.so (which is a GUI library, really dunno who 
put that here).
- getpass() doesn't exist, but I have a (yet unreleased)
library (libmoreposix) that provides a working version.
- the function receive_data() is reserved by the OS as part
of the native IPC mechanism, so I had to rename the static 
func receive_data() to resolve the namespace collision.
- I_SEXEC isn't defined (don't ask me why :)

Please CC me on answers as I'm not subscribed to this list.

François.

----
BeOS si dead.
Ugh ? http://OpenBeOS.org http://BeUnited.org http://yellowTAB.com
-------------- next part --------------
diff -urN rsync-2.5.6.org/clientserver.c rsync-2.5.6/clientserver.c
--- rsync-2.5.6.org/clientserver.c	Sun Jan 26 21:08:14 2003
+++ rsync-2.5.6/clientserver.c	Thu Feb 20 21:06:41 2003
@@ -314,11 +314,16 @@
 		 * a warning, unless a "require chroot" flag is set,
 		 * in which case we fail.
 		 */
+#ifndef HAVE_CHROOT
+		io_printf(f_out, "@ERROR: asked to chroot but not possible on host OS\n");
+		return -1;
+#else
 		if (chroot(lp_path(i))) {
 			rsyserr(FERROR, errno, "chroot %s failed", lp_path(i));
 			io_printf(f_out, "@ERROR: chroot failed\n");
 			return -1;
 		}
+#endif
 
 		if (!push_dir("/", 0)) {
                         rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
diff -urN rsync-2.5.6.org/configure.in rsync-2.5.6/configure.in
--- rsync-2.5.6.org/configure.in	Tue Jan 28 06:27:40 2003
+++ rsync-2.5.6/configure.in	Thu Feb 20 21:03:22 2003
@@ -301,8 +301,11 @@
 # libsocket.so which has a bad implementation of gethostbyname (it
 # only looks in /etc/hosts), so we only look for -lsocket if we need
 # it.
+# On the other hand, BeOS versions featuring BONE export legacy network
+# functions in both libnet.so (linked to by default), and libsocket.so
+# / libbind.so, which we _must_ link to if they exist.
 AC_CHECK_FUNCS(connect)
-if test x"$ac_cv_func_connect" = x"no"; then
+if test x"$ac_cv_func_connect" = x"no" -o x"$host_os" = x"beos"; then
     case "$LIBS" in
     *-lnsl*) ;;
     *) AC_CHECK_LIB(nsl_s, printf) ;;
@@ -330,6 +333,13 @@
 fi
 
 AC_CHECK_LIB(resolv, inet_ntop)
+if test x"$ac_cv_lib_resolv_inet_ntop" = x"no"; then
+	# BeOS versions featuring BONE have new network libs
+	# which contains them, but in a mangled form.
+	# FIXME: do a cleaner check (don't know autoconf enough)
+	AC_CHECK_LIB(bind, __inet_ntop)
+	# FIXME: define it as available on success
+fi
 
 dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
 
@@ -349,7 +359,10 @@
 			#endif], 
 			rsync_cv_HAVE_GETADDR_DEFINES=yes,
 			rsync_cv_HAVE_GETADDR_DEFINES=no)])
-if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
+
+AC_CHECK_LIB(bind, getaddrinfo)
+
+if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes" -a x"$rsync_cv_HAVE_GETADDRINFO" = x"no"; then
 	# Tru64 UNIX has getaddrinfo() but has it renamed in libc as
 	# something else so we must include <netdb.h> to get the
 	# redefinition.
@@ -413,7 +426,11 @@
 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo)
 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
 AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
-AC_CHECK_FUNCS(strlcat strlcpy strtol mtrace mallinfo setgroups)
+AC_CHECK_FUNCS(strlcat strlcpy strtol mtrace mallinfo setgroups chroot)
+
+AC_CHECK_LIB(be, openlog)
+AC_CHECK_LIB(posix, getpass)
+AC_CHECK_LIB(moreposix, getpass)
 
 AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
 AC_TRY_RUN([
diff -urN rsync-2.5.6.org/receiver.c rsync-2.5.6/receiver.c
--- rsync-2.5.6.org/receiver.c	Tue Jan 21 00:32:17 2003
+++ rsync-2.5.6/receiver.c	Thu Feb 20 20:28:14 2003
@@ -203,7 +203,7 @@
 }
 
 
-static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
+static int recv_data(int f_in,struct map_struct *buf,int fd,char *fname,
 			OFF_T total_size)
 {
 	int i;
@@ -383,14 +383,14 @@
 
 		if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
 			rprintf(FERROR,"fstat %s : %s\n",fnamecmp,strerror(errno));
-			receive_data(f_in,NULL,-1,NULL,file->length);
+			recv_data(f_in,NULL,-1,NULL,file->length);
 			close(fd1);
 			continue;
 		}
 
 		if (fd1 != -1 && !S_ISREG(st.st_mode)) {
 			rprintf(FERROR,"%s : not a regular file (recv_files)\n",fnamecmp);
-			receive_data(f_in,NULL,-1,NULL,file->length);
+			recv_data(f_in,NULL,-1,NULL,file->length);
 			close(fd1);
 			continue;
 		}
@@ -436,7 +436,7 @@
 		}
 		if (fd2 == -1) {
 			rprintf(FERROR,"mkstemp %s failed: %s\n",fnametmp,strerror(errno));
-			receive_data(f_in,buf,-1,NULL,file->length);
+			recv_data(f_in,buf,-1,NULL,file->length);
 			if (buf) unmap_file(buf);
 			if (fd1 != -1) close(fd1);
 			continue;
@@ -449,7 +449,7 @@
 		}
 
 		/* recv file data */
-		recv_ok = receive_data(f_in,buf,fd2,fname,file->length);
+		recv_ok = recv_data(f_in,buf,fd2,fname,file->length);
 
 		log_recv(file, &initial_stats);
 		
--- rsync-2.5.6.org/batch.c	Tue Dec 24 08:42:04 2002
+++ rsync-2.5.6/batch.c	Fri Feb 21 16:45:47 2003
@@ -8,6 +8,10 @@
 #include "rsync.h"
 #include <time.h>
 
+#ifndef S_IEXEC
+# define S_IEXEC 0x040
+#endif
+
 extern char *batch_prefix;
 
 struct file_list *batch_flist;
-------------- next part --------------
POSIXLY_CORRECT=1 TOOLDIR=`pwd` rsync_bin=`pwd`/rsync srcdir="." ./runtests.sh
============================================================
./runtests.sh running in /boot/home/devel/rsync-2.5.6
    rsync_bin=/boot/home/devel/rsync-2.5.6/rsync
    srcdir=.
    testuser=revol
    os=BeOS patrick 5.0.4 1000009 BePC unknown
    preserve_scratch=no
    scratchbase=/boot/home/devel/rsync-2.5.6/testtmp
PASS    00-hello
PASS    chgrp
PASS    chown
PASS    daemon-gzip-download
PASS    daemon-gzip-upload
PASS    daemon
SKIP    devices (Can't create char device node unless root)
SKIP    duplicates (Known minor bug in this code)
----- hands log follows
Testing for symlinks using 'test -h'
Test basic operation: Running: "/boot/home/devel/rsync-2.5.6/rsync -av /boot/home/devel/rsync-2.5.6/testtmp.hands/from/ /boot/home/devel/rsync-2.5.6/testtmp.hands/to"
building file list ... done
./
dir/
dir/subdir/
dir/subdir/subsubdir/
dir/subdir/subsubdir/etc-ltr-list
dir/subdir/subsubdir2/
dir/subdir/subsubdir2/bin-lt-list
dir/text
empty
emptydir/
filelist
nolf
nolf-symlink -> nolf
text
Kill Thread
-------------
check how the files compare with diff:

/bin/diff: /boot/home/devel/rsync-2.5.6/testtmp.hands/to/./dir/text: No such file or directory
/bin/diff: /boot/home/devel/rsync-2.5.6/testtmp.hands/to/./empty: No such file or directory
/bin/diff: /boot/home/devel/rsync-2.5.6/testtmp.hands/to/./filelist: No such file or directory
/bin/diff: /boot/home/devel/rsync-2.5.6/testtmp.hands/to/./nolf: No such file or directory
/bin/diff: /boot/home/devel/rsync-2.5.6/testtmp.hands/to/./text: No such file or directory
-------------
check how the directory listings compare with diff:

*** /boot/home/devel/rsync-2.5.6/testtmp.hands/ls-from  Fri Feb 21 16:35:12 2003
--- /boot/home/devel/rsync-2.5.6/testtmp.hands/ls-to    Fri Feb 21 16:35:12 2003
***************
*** 1,14 ****
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:54 .
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:54 ./dir
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:55 ./dir/subdir
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:55 ./dir/subdir/subsubdir
  -rw-r--r--           78      0.0           1 2003-02-21 15:30:55 ./dir/subdir/subsubdir/etc-ltr-list
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:55 ./dir/subdir/subsubdir2
  -rw-r--r--           78      0.0           1 2003-02-21 15:30:55 ./dir/subdir/subsubdir2/bin-lt-list
- -rw-r--r--       374535      0.0           1 2003-02-21 15:30:54 ./dir/text
- -rw-r--r--            0      0.0           1 2003-02-21 15:30:52 ./empty
  drwxr-xr-x            0      0.0           1 2003-02-21 15:30:52 ./emptydir
- -rw-r--r--        21582      0.0           1 2003-02-21 15:30:53 ./filelist
- -rw-r--r--           28      0.0           1 2003-02-21 15:30:53 ./nolf
  l---------            0      0.0           1                     ./nolf-symlink -> nolf
- -rw-r--r--       374535      0.0           1 2003-02-21 15:30:54 ./text
--- 1,10 ----
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:56 .
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:56 ./dir
! -rw-------    103776256      0.0           1 2003-02-21 15:31:49 ./dir/.text.z2dOdy
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:56 ./dir/subdir
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:56 ./dir/subdir/subsubdir
  -rw-r--r--           78      0.0           1 2003-02-21 15:30:55 ./dir/subdir/subsubdir/etc-ltr-list
! drwxr-xr-x            0      0.0           1 2003-02-21 15:30:56 ./dir/subdir/subsubdir2
  -rw-r--r--           78      0.0           1 2003-02-21 15:30:55 ./dir/subdir/subsubdir2/bin-lt-list
  drwxr-xr-x            0      0.0           1 2003-02-21 15:30:52 ./emptydir
  l---------            0      0.0           1                     ./nolf-symlink -> nolf
 failed!
----- hands log ends
FAIL    hands
----- hardlinks log follows
Testing for symlinks using 'test -h'
+ fromdir=/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from
+ todir=/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/to
+ mkdir /boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from
+ name1=/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name1
+ name2=/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name2
+ name3=/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name3
+ name4=/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name4
+ echo 'This is the file'
+ ln /boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name1 /boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name2
/bin/ln: cannot create hard link `/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name2' to `/boot/home/devel/rsync-2.5.6/testtmp.hardlinks/from/name1': Invalid argument
+ fail 'Can'\''t create hardlink'
./testsuite/hardlinks.test: fail: command not found
----- hardlinks log ends
FAIL    hardlinks
----- longdir log follows
Testing for symlinks using 'test -h'
        makepath /boot/home/devel/rsync-2.5.6/testtmp.longdir/from/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job
Running: "/boot/home/devel/rsync-2.5.6/rsync --delete -avH /boot/home/devel/rsync-2.5.6/testtmp.longdir/from/ /boot/home/devel/rsync-2.5.6/testtmp.longdir/to"
building file list ... done
./
This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/
This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/
This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/1
This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/2
dir/
dir/subdir/
dir/subdir/subsubdir/
dir/subdir/subsubdir/etc-ltr-list
dir/subdir/subsubdir2/
dir/subdir/subsubdir2/bin-lt-list
dir/text
empty
emptydir/
filelist
nolf
nolf-symlink -> nolf
text
Kill Thread
----- longdir log ends
FAIL    longdir
SKIP    ssh-basic (Skipping SSH tests because $rsync_enable_ssh_tests is not set)
PASS    symlink-ignore
PASS    trimslash
PASS    unsafe-byname
PASS    unsafe-links
------------------------------------------------------------
----- overall results:
      10 passed
      3 failed
      3 skipped
------------------------------------------------------------
overall result is 3
make: *** [check] Error 3


More information about the rsync mailing list