Hylafax Developers Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

[hylafax-devel] Fwd: File open patch (fwd)



Hi,

I'm not sure if this got through yesterday so i am resending it...

PS Does anyone have any information on the tiff 3.5 problem, even  just a 
core dump to give an idea where the software fails would be good.

- Robert



>---------- Forwarded message ----------
>Date: Fri, 17 Mar 2000 12:54:24 +1100 (EDT)
>From: Robert Colquhoun <rjc@kd.com.au>
>To: hylafax-devel@hylafax.org
>Subject: File open patch
>
>
>Hi,
>
>Attached is a patch to fix the O_EXCL problem, could someone please try
>this out to see if it will work and i will commit the change.
>
>- Robert

Index: HylaFAXServer.c++
===================================================================
RCS file: /usr/local/cvsroot/hylafax/hfaxd/HylaFAXServer.c++,v
retrieving revision 1.7
diff -u -r1.7 HylaFAXServer.c++
--- HylaFAXServer.c++	1999/11/18 12:18:57	1.7
+++ HylaFAXServer.c++	2000/03/17 05:38:15
@@ -512,7 +512,22 @@
 u_int
 HylaFAXServer::getSequenceNumber(const char* filename, u_int count, fxStr& emsg)
 {
-    int fd = Sys::open(filename, O_CREAT|O_RDWR|O_EXCL, 0600);
+    struct stat sb;
+    int fd;
+    int rtn = lstat(filename, &sb);
+    if (rtn == ENOENT) {
+        fd = Sys::open(filename, O_CREAT | O_RDWR | O_EXCL, 0600);
+    } else if (rtn == 0 && S_ISREG(sb.st_mode)) {
+        fd = Sys::open(filename, O_RDWR, 0600);
+        struct stat sb2;
+        if (fstat(fd, &sb2) || sb.st_ino != sb2.st_ino || sb.st_dev != sb2.st_dev) {
+            //XXX some kind of error opening file
+            fd = -1;
+        }
+    } else {
+        //XXX some kind of error opening file
+        fd = -1;
+    }
     if (fd < 0) {
         emsg = fxStr::format("Unable to open sequence number file %s; %s.",
             filename, strerror(errno));



Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services