2004年7月5日(月)

Ken Thompson 最大の不覚

ちと gfarm というデータグリッドを FreeBSD/MacOSX 環境にインストールしようとして SYS_creat なんてのに立ちはだかれてしまってしばらく悩む。

creat system call は open(2) でいいじゃん、ってことで obsolete なんだが、なまじ NetBSD あたりだと compat43 当たりに存在していてくれて,何故かこいつは動作環境が Linux/NetBSD だったり…

よぉく man page 読むと,ちゃんと open(2) の第2引数が O_CREAT の時は第3引数に mode を取るってことで完全に統合されてるんですが linux だと違うんかな?


やれやれ…と思ったらまだあった。なに? fdatasync ?
メタデータは触らずデータだけ flush するから早いって? linux にはこんなのあるのか

どうでもいいが、未だに MacOSX を知らない config.guess とかつけてくるなよ

FreeBSD では ports あたりから OpenLDAP をインストールしておくこと
MacOSX では、 tar 玉展開後、 cp /usr/share/libtool/config.* . し、さらに mv util/gfront/GFront util/gfront/GFront_java としておく。
以下のパッチを当て、 configure 以下省略

--- lib/gfs_hook/hooks.c.orig   Tue May 11 11:30:42 2004
+++ lib/gfs_hook/hooks.c        Mon Jul  5 22:50:37 2004
@@ -30,6 +30,9 @@
 #define SYS_fstat SYS___fstat13
 #define SYS_lstat SYS___lstat13
 #endif
+#if defined(__POWERPC__)
+#define SYS_getdents SYS_getdirentries
+#endif
 
 #ifdef __linux__
 #include 
@@ -688,7 +691,11 @@
 int
 gfs_hook_syscall_creat(const char *path, mode_t mode)
 {
+#if defined(__FreeBSD__) || defined(__POWERPC__)
+       return (syscall(SYS_open, path, O_CREAT, mode));
+#else
        return (syscall(SYS_creat, path, mode));
+#endif
 }
 
 off_t
--- lib/libgfarm/gfarm/gfs_unlink.c.orig        Sat Feb 14 01:09:13 2004
+++ lib/libgfarm/gfarm/gfs_unlink.c     Mon Jul  5 16:45:10 2004
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
--- lib/libgfarm/gfarm/gfs_pio_remote.c.orig    Sun Sep 21 22:09:25 2003
+++ lib/libgfarm/gfarm/gfs_pio_remote.c Mon Jul  5 16:43:35 2004
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include  /* struct sockaddr */
 #include 
 #include 
--- server/gfmd/gfmd.c.orig     Fri Dec  5 00:10:06 2003
+++ server/gfmd/gfmd.c  Mon Jul  5 21:50:33 2004
@@ -3,6 +3,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
--- server/gfsd/gfsd.c.orig     Fri Dec  5 00:10:06 2003
+++ server/gfsd/gfsd.c  Mon Jul  5 22:10:33 2004
@@ -964,7 +964,11 @@
                                written += rv;
                                if (written >= file_sync_rate) {
                                        written -= file_sync_rate;
+#if defined(__FreeBSD__) || defined(__POWERPC__)
+                                       fsync(ofd);
+#else
                                        fdatasync(ofd);
+#endif
                                }
                        }
                        if (--nfound <= 0)
--- lib/libgfarm/gfarm/gfs_client.c.orig        Mon May 24 18:34:04 2004
+++ lib/libgfarm/gfarm/gfs_client.c     Mon Jul  5 22:11:56 2004
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -664,7 +665,11 @@
                                written += rv;
                                if (written >= sync_rate) {
                                        written -= sync_rate;
+#if defined(__FreeBSD__) || defined(__POWERPC__)
+                                       fsync(fd);
+#else
                                        fdatasync(fd);
+#endif
                                }
                        }
                }
@@ -715,7 +720,11 @@
                                        written += rv;
                                        if (written >= sync_rate) {
                                                written -= sync_rate;
+#if defined(__FreeBSD__) || defined(__POWERPC__)
+                                               fsync(fd);
+#else
                                                fdatasync(fd);
+#endif
                                        }
                                }
                        }
--- gfptool/gfrepbe_client/gfrepbe_client.c.orig        Mon Jul  5 22:54:26 2004
+++ gfptool/gfrepbe_client/gfrepbe_client.c     Mon Jul  5 22:56:00 2004
@@ -62,7 +62,11 @@
                        *disksync_cyclep += rv;
                        if (*disksync_cyclep >= file_sync_rate) {
                                *disksync_cyclep -= file_sync_rate;
+#if defined(__FreeBSD__) || defined(__POWERPC__)
+                               fsync(fd);
+#else
                                fdatasync(fd);
+#endif
                        }
                }
        }
@@ -90,7 +94,11 @@
                        *disksync_cyclep += rv;
                        if (*disksync_cyclep >= file_sync_rate) {
                                *disksync_cyclep -= file_sync_rate;
+#if defined(__FreeBSD__) || defined(__POWERPC__)
+                               fsync(fd);
+#else
                                fdatasync(fd);
+#endif
                        }
                }
        }
@@ -257,7 +265,11 @@
                                    transfers[i]);
                        if (file_sync_stripe > 0) {
                                if (++k >= file_sync_stripe) {
+#if defined(__FreeBSD__) || defined(__POWERPC__)
+                                       fsync(ofd);
+#else
                                        fdatasync(ofd);
+#endif
                                        k = 0;
                                }
                        }
--- lib/gfs_hook/hooks_common.c.orig    Thu Feb 26 14:54:57 2004
+++ lib/gfs_hook/hooks_common.c Mon Jul  5 23:33:53 2004
@@ -444,8 +444,10 @@
 }
 
 int internal_function
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
 FUNC_GETDENTS(int filedes, char *buf, size_t nbyte)
+#elif defined(__FreeBSD__)
+FUNC_GETDENTS(int filedes, char *buf, int nbyte)
 #else
 FUNC_GETDENTS(int filedes, STRUCT_DIRENT *buf, size_t nbyte)
 #endif

[referer:

Script Error

The script did not produce proper HTTP headers. Please see the error log to see the detail of the errors. Depending on the server configuration, you can also run thisscript under CGIWrap debugging. Usually, either rename or linkthe script temporarily to a file which ends with .cgidextension, or add a AddHandler cgi-script-debug .cgiline to your .htaccess file.

]

あわせて読みたい