Re: a ld_preload to get rvplayer working

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Thu, 19 Nov 1998 11:24:56 +0000


On Wed, Nov 18, 1998 at 09:06:33AM +0000, Paul wrote:
> #define O_NONBLOCK 04000
> extern int libc_open(const char *, int);
> int open(const char *pathname, int flags)
> {
> if (flags & O_NONBLOCK)
> flags &= ~O_NONBLOCK;
> return(__open(pathname, flags));
> }
>
> Compile it with "gcc -c open.c -o open.o ; ld -shared open.o -o open.so"
> Then run run rvplayer with "LD_PRELOAD=/path/open.so /path/rvplayer"
> Works for me anyway, and I don't have to reboot to listen to broadcasts.

Fine, but a bit of potential for some other bug do to always unmasking
O_NONBLOCK, don't you think?

I use this one, compile in much the same way:

#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#define open __not_open
#include <fcntl.h>
#undef open

/* Change open("/dev/dsp", O_WRONLY|O_NONBLOCK) for RealAudio and Linux 2.1.x.
Change open("/dev/dsp", O_RDWR|O_NONBLOCK) for Timidity 0.2i.
Change open("/dev/dsp", O_RDWR) for Quake and Linux 2.1.x. */

int open (const char * pathname, int flags, mode_t mode)
{
if (!strcmp (pathname, "/dev/dsp") && (flags &= ~O_NONBLOCK) == O_RDWR)
flags = O_WRONLY;
return __open (pathname, flags, mode);
}

-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/