Hylafax Developers Mailing List Archives
|
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[hylafax-devel] Re: Fwd: File open patch (fwd)
At 06:39 PM 3/18/00 -0800, Tim Rice wrote:
>This patch doesn't work.
>-----
># pwd
>/var/spool/fax
># ls -l */seqf
>UX:ls: ERROR: Cannot access */seqf: No such file or directory
>#
>-----
>tim(trr)@uw71 1% sendfax -d 555.1212 x
>553 Unable to open sequence number file docq/seqf; No such file or directory.
>tim(trr)@uw71 2%
Are you sure you restarted hfaxd?
Attached is a slightly modified patch, could you try that.
- 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/19 08:33:18
@@ -512,7 +512,25 @@
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 (fd < 0 || fstat(fd, &sb2)) {
+ //XXX some kind of error opening file
+ fd = -1;
+ } else if (sb.st_ino != sb2.st_ino || sb.st_dev != sb2.st_dev) {
+ //XXX something wrong with 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));