Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD support... #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ case "$os" in
plat_cflags="$plat_cflags -DAT_REMOVEDIR=0x200"
CC=clang
;;
FreeBSD)
plat_files="$plat_files ../src/compat/clearenv.c "
plat_files="$plat_files ../src/compat/dir_mutex.c "
plat_files="$plat_files ../src/compat/utimensat.c"
;;
esac

rm -rf build
Expand Down
6 changes: 3 additions & 3 deletions src/tup/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__)
#include <sys/sysctl.h>
#elif defined(_WIN32)
/* Don't let Windows define SLIST_ENTRY and conflict with bsd/queue.h */
Expand Down Expand Up @@ -290,9 +290,9 @@ static const char *cpu_number(void)
static char buf[10];

int count = 1;
#if defined(__linux__) || defined(__sun__)
#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)
count = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(__APPLE__) || defined(__FreeBSD__)
#elif defined(__APPLE__)
int nm[2];
size_t len = 4;

Expand Down
2 changes: 2 additions & 0 deletions src/tup/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
/* NOTE: Please keep the list in tup.1 in sync */
#ifdef __linux__
const char *tup_platform = "linux";
#elif __FreeBSD__
const char *tup_platform = "freebsd";
#elif __sun__
const char *tup_platform = "solaris";
#elif __APPLE__
Expand Down
10 changes: 10 additions & 0 deletions src/tup/server/fuse_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
/* For pread()/pwrite() */
#define _XOPEN_SOURCE 500
#endif
#ifdef __FreeBSD__
/* For S_IFDIR */
# define __XSI_VISIBLE 1
/* For AT_SYMLINK_NOFOLLOW */
# define __BSD_VISIBLE 1
#endif

#include "compat/utimensat.h"
#include "tup_fuse_fs.h"
Expand All @@ -38,6 +44,10 @@
#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#ifdef __FreeBSD__
# include <fcntl.h>
# include <sys/stat.h>
#endif

static struct thread_root troot = THREAD_ROOT_INITIALIZER;
static int server_mode = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/tup/server/fuse_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int os_unmount(void)
}
return rc;
}
#elif defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__)
static int os_unmount(void)
{
if(unmount(TUP_MNT, MNT_FORCE) < 0) {
Expand Down
13 changes: 11 additions & 2 deletions src/tup/server/master_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include <errno.h>
#include <sys/socket.h>
#include <sys/wait.h>
#ifdef __FreeBSD__
# include <sys/param.h>
#endif
#include <sys/mount.h>
#include <signal.h>

Expand Down Expand Up @@ -279,12 +282,18 @@ static int setup_subprocess(tupid_t sid, const char *job, const char *dir,
fprintf(stderr, "tup internal error: Trying to run sub-process in a chroot, but tup is not privileged.\n");
return -1;
}
#ifdef __APPLE__
#if defined(__APPLE__)
if(mount("devfs", dev, MNT_DONTBROWSE, NULL) < 0) {
perror("mount");
fprintf(stderr, "tup error: Unable to mount /dev into fuse file-system.\n");
return -1;
}
#elif defined(__FreeBSD__)
if(mount("devfs", dev, 0, NULL) < 0) {
perror("mount");
fprintf(stderr, "tup error: Unable to mount /dev into fuse file-system.\n");
return -1;
}
#else
/* The "tmpfs" argument is ignored since we use MS_BIND, but
* valgrind complains about it if we use NULL.
Expand Down Expand Up @@ -548,7 +557,7 @@ static void *child_waiter(void *arg)
}
if(waiter->do_chroot && tup_privileged()) {
int rc;
#ifdef __APPLE__
#if defined(__APPLE__) || defined(__FreeBSD__)
rc = unmount(waiter->dev, MNT_FORCE);
#else
rc = umount2(waiter->dev, MNT_FORCE);
Expand Down
2 changes: 1 addition & 1 deletion tup.1
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ In tup.config, comments are determined by a '#' character in the first column. T
In this case, the @-variable "FOO" is explicitly set to "n".
.TP
.B @(TUP_PLATFORM)
TUP_PLATFORM is a special @-variable. If CONFIG_TUP_PLATFORM is not set in the tup.config file, it has a default value according to the platform that tup itself was compiled in. Currently the default value is one of "linux", "solaris", "macosx", or "win32".
TUP_PLATFORM is a special @-variable. If CONFIG_TUP_PLATFORM is not set in the tup.config file, it has a default value according to the platform that tup itself was compiled in. Currently the default value is one of "linux", "freebsd", "solaris", "macosx", or "win32".
.TP
.B @(TUP_ARCH)
TUP_ARCH is another special @-variable. If CONFIG_TUP_ARCH is not set in the tup.config file, it has a default value according to the processor architecture that tup itself was compiled in. Currently the default value is one of "i386", "x86_64", "powerpc", "powerpc64", "ia64", "alpha", "sparc" or "arm".
Expand Down