diff options
author | Anton Berezin <tobez@FreeBSD.org> | 2002-01-22 22:09:27 +0000 |
---|---|---|
committer | Anton Berezin <tobez@FreeBSD.org> | 2002-01-22 22:09:27 +0000 |
commit | 13333425adea6a26a61e51182741647c22b2baca (patch) | |
tree | 2fc2fb764c375d6aa67a2f629af8aba51d75c504 /misc/afbackup/files | |
parent | dbf60cf1931b99f132a15b1df085340965fe9ddd (diff) |
Notes
Diffstat (limited to 'misc/afbackup/files')
-rw-r--r-- | misc/afbackup/files/patch-aj | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/misc/afbackup/files/patch-aj b/misc/afbackup/files/patch-aj new file mode 100644 index 000000000000..c5d60559655d --- /dev/null +++ b/misc/afbackup/files/patch-aj @@ -0,0 +1,42 @@ +--- sysutils.c.orig Wed Sep 12 20:29:45 2001 ++++ sysutils.c Mon Jan 21 21:55:47 2002 +@@ -37,6 +37,9 @@ + #include <grp.h> + #include <sysutils.h> + #include <fileutil.h> ++#ifdef __FreeBSD__ ++#include <sys/sysctl.h> ++#endif + + #define GETOUT { goto getout; } + #define CLEANUP { goto cleanup; } +@@ -763,9 +766,20 @@ + Int32 + free_fds() + { +- int *fds = NULL, *newfds = NULL, fd; + Int32 num_fds = 0; + ++#ifdef __FreeBSD__ ++ /* This code is for avoiding race conditions with other processes which ++ * might need a spare file descriptor while afbackup tries to find out ++ * how many of those it can use. sysctl gives us more general yet less ++ * reliable answer as it is does not count on a number of possibly ++ * opened files. */ ++ size_t sz = sizeof( Int32); ++ ++ sysctlbyname( "kern.maxfilesperproc", &num_fds, &sz, NULL, 0); ++#else ++ int *fds = NULL, *newfds = NULL, fd; ++ + while((fd = open(NULLDEV, O_RDONLY)) >= 0){ + newfds = ZSRENEWP(fds, int, num_fds + 1, num_fds); + +@@ -784,6 +798,7 @@ + close(fds[fd]); + + free(fds); ++#endif + + return(num_fds); + } |