summaryrefslogtreecommitdiff
path: root/filesystems/fuse-chironfs/patches/patch-ab
blob: 9777561733b2ec064bf1dc48094825394656bdd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
$NetBSD: patch-ab,v 1.1.1.1 2007/11/27 18:55:40 pooka Exp $

--- src/chiron-conf.c.orig	2007-10-23 04:54:53.000000000 +0200
+++ src/chiron-conf.c	2007-11-27 18:05:11.000000000 +0100
@@ -34,7 +34,11 @@
 #include <dlfcn.h>
 
 #include <libgen.h>
+#ifdef __linux__
 #include <linux/limits.h>
+#else
+#include <limits.h>
+#endif
 #include <string.h>
 #include <stdint.h>
 #include <sys/resource.h>
@@ -232,7 +236,8 @@
 int do_mount(char *filesystems, char *mountpoint)
 {
    char   buf[100];
-   int    i, start, fd, res, errno, rep_on_mount=0, err;
+   int    fd, res;
+   int    i, start, errno, rep_on_mount=0, err;
    int    *tmp_high, *tmp_low;
    unsigned long tmpfd;
    struct rlimit rlp;
@@ -249,21 +254,21 @@
    }
 
    fd = open("/proc/sys/fs/file-max",O_RDONLY);
-   if (fd<0) {
-      print_err(errno,"opening /proc/sys/fs/file-max");
-      exit(errno);
-   }
-   res = read(fd,buf,99);
-   if (res<0) {
-      print_err(errno,"reading /proc/sys/fs/file-max");
-      exit(errno);
+   if (fd != -1) {
+      res = read(fd,buf,99);
+      if (res<0) {
+         print_err(errno,"reading /proc/sys/fs/file-max");
+         exit(errno);
+      }
+      sscanf(buf,"%qu",&FD_BUF_SIZE);
+      close(fd);
+   } else {
+      FD_BUF_SIZE = 4096;
    }
-   sscanf(buf,"%qu",&FD_BUF_SIZE);
-   close(fd);
    
    tmpfd = (FD_BUF_SIZE >>= 1);
 
-   if (getrlimit(RLIMIT_OFILE,&rlp)) {
+   if (getrlimit(RLIMIT_NOFILE,&rlp)) {
       print_err(errno,"reading nofile resource limit");
       exit(errno);
    }
@@ -356,11 +361,11 @@
    }
 
    if (mountpoint[0]==':') {
-      mount_point = realpath(mountpoint+1,NULL);
+      mount_point = do_realpath(mountpoint+1,NULL);
       rep_on_mount = i = 1;
       tmp_high[max_replica_high++] = 0;
    } else {
-      mount_point = realpath(mountpoint,NULL);
+      mount_point = do_realpath(mountpoint,NULL);
       i = 0;
    }
    if (mount_point==NULL) {
@@ -380,7 +385,7 @@
          tmp_high[max_replica_high++] = i;
       }
 
-      paths[i].path = realpath(filesystems+start, NULL);
+      paths[i].path = do_realpath(filesystems+start, NULL);
       if (paths[i].path==NULL) {
          free_paths();
          free_tab_fd();