[Thread Prev][Thread Next][Index]
hack to run ferret on RO FS. (Was Re: Ferret open .jnl file rw ?)
Hi,
I've *temporary* solved my problem, with a so ugly hack:
I've overload the fopen libc function to set errno whith EACCES when it
is EROFS...
#include <stdlib.h>
#include <dlfcn.h>
#include <signal.h>
#include <errno.h>
FILE *fopen(const char *path, const char *mode){
static FILE *(*RealFopen)(const char *path, const char *mode)=0;
FILE *fid;
// set it up only once
if (!RealFopen){
RealFopen=dlsym(((void *) -1l), "fopen");
if (!RealFopen){
fprintf(stderr, "Fatal error - cannot find fopen()\n");
abort();
}
}
fid= RealFopen(path,mode);
/* force errno to be EACCES if it is EROFS */
if( (fid == NULL) && ( errno == EROFS ) ){ errno=EACCES; }
return fid;
}
%gcc -o fopen.so -shared fopen.c
%setenv LD_PRELOAD fopen.so
%ferret
This hack permit me go ahead with LAS, but I think something is doable
source side...
--
Olivier
Olivier ARCHER wrote:
Hi again, still investgating....
I've noticed that if the 'go' statement fail with 'permission denied',
ferret try to open it ro. ie:
wlos datacer:/home/biblios/las/server/jnls# cat test.jnl
message hello ferret
wlos datacer:/home/biblios/las/server/jnls# ls -l test.jnl
-r--r--r-- 1 www-data www-data 21 Apr 30 13:34 test.jnl
if I now run ferret as root, it work. strace says:
open("./test.jnl", O_RDWR) = -1 EACCES (Permission denied)
open("./test.jnl", O_RDONLY) = 3
so ferret see that he cannot open rw, so he open ro. great!
But if i run ferret as www-data user i've got:
**ERROR: test: Read-Only file system
and strace *only* say:
open("./test.jnl", O_RDWR) = -1 EROFS (Read-only file
system)
and ferret doesn't try to open it ro ...
So i think that ferret handle correctly EACCESS error, falling back to
RO. But the EROFS error seem to not be handled correctly... probably
something like
if (errno == EACCESS ) as to be changed to
if ( (errno == EACCESS) || (errno ==EROFS) )
I havent the ferret source code to check and try.... And reading
source code is more understandable than strace...
Is someone who have acces to source code can check ? Or maybe someone
can send it to me ?
Thx
--
Olivier
Olivier ARCHER wrote:
Hi,
I'm very new to ferret, and i using it in conjuction with Live
Access Server.
When Ferret trie on my system (linux 2.4.18 debian) to access a .jnl
file, it try to open it RW. But .jnl file are on nfs ro and ferret
complain...
*Adding an acceptable error string: "*** NOTE: ".
NOAA/PMEL TMAP
FERRET v5.41 Linux 2.4.3-12smp - 08/30/02
25-Apr-03 08:49 yes? cancel mode verify
yes? cancel mode interp
yes? canc data/all
yes? go std_initialize
"http://wlos.ifremer.fr:8094/dodsC/MWF/NSCAT/WEEK" "1" "1" "wind_speed"
**ERROR: std_initialize: Read-only file system
I've straced ferret, and here are the last signifiant lines:
*read(0, "go std_initialize \"http://wlos.i"..., 4096) = 90
write(5, "go std_initialize \"http://wlos.i"..., 90) = 90
access("/home/biblios/las/server/jnls/std_initialize.jnl", F_OK) = 0
access("/home/biblios/las/server/jnls/std_initialize.jnl", F_OK) = 0
open("/home/biblios/las/server/jnls/std_initialize.jnl", O_RDWR) = -1
EROFS (Read-only file system)
open("/home/biblios/las/server/jnls/std_initialize.jnl", O_RDWR) = -1
EROFS (Read-only file system)
dup(2) = 6
fcntl64(6, F_GETFL) = -1 ENOSYS (Function not
implemented)
fcntl(6, F_GETFL) = 0x1 (flags O_WRONLY)
close(6) = 0
fstat(2, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x41c34000
write(2, "**ERROR: std_initialize: Read-on"..., 47) = 47
write(1, "yes? ", 5) = 5
read(0,
Is there a directive to say that ferret must open .jnl file RO ?
--
Olivier
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement