Hello all, I'd like to have comments on this patch, which is intended to make darcs ignore sockets when slurping. It sounds like a good idea to me, but I was hoping that someone with longer unix experience than I could comment on its advasability and implementation.
It starts getting a bit confusing, and makes me wonder whether we ought to
be developing some simpler and more unified framework.
David.
----- Forwarded message from Isaac Jones <[EMAIL PROTECTED]> -----
Envelope-to: [EMAIL PROTECTED]
Delivery-date: Thu, 28 Jul 2005 21:15:29 -0400
To: David Roundy <[EMAIL PROTECTED]>
Subject: [Matt Kraai] Bug#304264: Patch for ignoring sockets
From: Isaac Jones <[EMAIL PROTECTED]>
David. I'm not sure what the use case for this is, but I thought I'd
pass it along.
peace,
isaac
Subject: Bug#304264: Patch for ignoring sockets
Reply-To: Matt Kraai <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
From: Matt Kraai <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
tag 304264 patch
thanks
The attached patch should make darcs ignore sockets. I haven't tested
it, though.
--
Matt
diff -ru darcs-1.0.3.orig/compat.c darcs-1.0.3/compat.c
--- darcs-1.0.3.orig/compat.c 2005-04-20 12:00:04.000000000 -0700
+++ darcs-1.0.3/compat.c 2005-07-28 07:49:52.929674416 -0700
@@ -194,6 +194,10 @@
return _pipe(fildes, 8 * (2<<10), O_BINARY);
}
+int is_socket(const char *file) {
+ return 0;
+}
+
int is_symlink(const char *file) {
return 0; /* FIXME: should ignore windows shortcuts */
}
@@ -294,6 +298,12 @@
#include <sys/types.h>
#include <sys/stat.h>
+int is_socket(const char *file) {
+ struct stat buf;
+ if (lstat(file, &buf)) return 0; /* treat error as non-socket */
+ return S_ISSOCK(buf.st_mode);
+}
+
int is_symlink(const char *file) {
struct stat buf;
if (lstat(file, &buf)) return 0; /* treat error as non-symlink */
diff -ru darcs-1.0.3.orig/compat.h darcs-1.0.3/compat.h
--- darcs-1.0.3.orig/compat.h 2005-03-18 05:12:16.000000000 -0800
+++ darcs-1.0.3/compat.h 2005-07-28 07:48:33.691720416 -0700
@@ -21,6 +21,7 @@
int execvp_no_vtalarm(const char *file, char *const argv[]);
+int is_socket(const char *file);
int is_symlink(const char *file);
int stdout_is_a_pipe();
diff -ru darcs-1.0.3.orig/SlurpDirectory.lhs darcs-1.0.3/SlurpDirectory.lhs
--- darcs-1.0.3.orig/SlurpDirectory.lhs 2005-03-18 05:12:16.000000000 -0800
+++ darcs-1.0.3/SlurpDirectory.lhs 2005-07-28 07:52:49.450839120 -0700
@@ -146,6 +146,14 @@
-- with older versions, though, we just ignore sleep's return
-- value. Hackery, like I said.
+foreign import ccall unsafe "static compat.h is_socket" is_socket
+ :: CString -> IO Int
+
+isFileReallySocket :: FilePath -> IO Bool
+isFileReallySocket f = do
+ withCString f $ \cf -> do sock <- is_socket cf
+ return $ sym /= 0
+
foreign import ccall unsafe "static compat.h is_symlink" is_symlink
:: CString -> IO Int
@@ -159,7 +167,9 @@
fe <- doesFileExist f
if not fe then return False
else do symlink <- isFileReallySymlink f
- return $ not symlink
+ if symlink then return False
+ else do socket <- isFileReallySocket f
+ return $ not socket
doesDirectoryReallyExist :: FilePath -> IO Bool
doesDirectoryReallyExist f = do
fe <- doesDirectoryExist f
----- End forwarded message -----
--
David Roundy
http://www.darcs.net
signature.asc
Description: Digital signature
_______________________________________________ darcs-devel mailing list [email protected] http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel
