15 |
|
#include "view.h" |
16 |
|
#include "resolu.h" |
17 |
|
|
18 |
+ |
#ifndef NFS |
19 |
+ |
#define NFS 1 |
20 |
+ |
#endif |
21 |
|
/* set the following to 0 to forgo forking */ |
22 |
|
#ifndef MAXFORK |
23 |
+ |
#if NFS |
24 |
|
#define MAXFORK 3 /* allotment of duped processes */ |
25 |
+ |
#else |
26 |
+ |
#define MAXFORK 0 |
27 |
|
#endif |
28 |
+ |
#endif |
29 |
|
|
30 |
|
/* rpict command */ |
31 |
|
char *rpargv[128] = {"rpict", "-S", "1", "-x", "512", "-y", "512", "-pa", "1"}; |
186 |
|
scanorig = ftell(fp); /* record position of first scanline */ |
187 |
|
if (fclose(fp) == -1) /* done with stream i/o */ |
188 |
|
goto filerr; |
189 |
+ |
#if NFS |
190 |
|
sync(); /* flush NFS buffers */ |
191 |
+ |
#endif |
192 |
|
/* start rpict process */ |
193 |
|
if (open_process(rpd, rpargv) <= 0) { |
194 |
|
fprintf(stderr, "%s: cannot start %s\n", progname, rpargv[0]); |
361 |
|
#else |
362 |
|
pid = -1; /* no forking */ |
363 |
|
#endif |
364 |
+ |
#if NFS |
365 |
|
/* lock file section so NFS doesn't mess up */ |
366 |
|
fls.l_whence = 0; |
367 |
|
fls.l_len = (long)vres*hmult*hres*sizeof(COLR); |
368 |
|
fls.l_start = scanorig + (vmult-1-ypos)*fls.l_len; |
369 |
|
fls.l_type = F_WRLCK; |
370 |
|
fcntl(outfd, F_SETLKW, &fls); |
371 |
+ |
#endif |
372 |
|
/* write new piece to file */ |
373 |
|
if (lseek(outfd, fls.l_start+(long)xpos*hres*sizeof(COLR), 0) == -1) |
374 |
|
goto seekerr; |
387 |
|
goto seekerr; |
388 |
|
} |
389 |
|
if (pid == -1) { /* fork failed */ |
390 |
+ |
#if NFS |
391 |
|
fls.l_type = F_UNLCK; /* release lock */ |
392 |
|
fcntl(outfd, F_SETLKW, &fls); |
393 |
+ |
#endif |
394 |
|
return(0); |
395 |
|
} |
396 |
|
_exit(0); /* else exit child process (releasing lock) */ |