File:  [DVB] / dietlibc / libdl / _dl_open.c
Revision 1.19: download - view: text, annotated - select for diffs
Mon Mar 11 19:21:12 2002 UTC (22 years, 3 months ago) by olaf
Branches: MAIN
CVS tags: finnland_test_200301, branch_rc14_fieldtest_finnland, branch_rc13_fieldtest_finnland, branch_rc12_fieldtest_finnland, branch_rc10_fieldtest_finnland, RELEASE_finnland_200301_1, RC12_FIELDTEST_FINNLAND, RC10_FIELDTEST_FINNLAND, HEAD
- so now the new dynamic-linker is working; some more tests and then it's
  the default...
- modified the old one so it still can be used.
- recode the DEBUG code so it can be used in the minimalistic syscall
  enviroment of the libdl.so/dynlinker (only a sub-subset is available)
All in one line:
  libdl.so+dynlinker < 10k on x86 :)

#include <fcntl.h>
#include <dlfcn.h>
#include <limits.h>
#ifndef __DIET_LD_SO__
#include <string.h>
#endif

#include "_dl_int.h"

#ifdef __DIET_LD_SO__
static
#endif
void*_dl_open(const char*filename,int flags) {
  int fd;
  char buf[PATH_MAX];
  const char*p=0;

  for (fd=0;filename[fd] && (p==0);++fd) if (filename[fd]=='/') p=filename;
  if (p) {
#ifdef __DIET_LD_SO__
    if ((fd=_dl_sys_open(p,O_RDONLY,0))<0) fd=-1;
#else
    fd=open(p,O_RDONLY);
#endif
  } else {
    p=buf;
    fd=_dl_search(buf,sizeof(buf)-1,filename);
  }
  if (fd==-1) {
    _dl_error_data=filename;
    _dl_error=1;
    return 0;
  }
  return _dl_load(filename,p,fd,flags);
}

LinuxTV legacy CVS <linuxtv.org/cvs>