Exemple #1
0
int sys_openat(int dirfd, const char* name, int flags, int mode)
{
  int kfd = at_kfd(dirfd);
  if (kfd != -1) {
    file_t* file = file_openat(kfd, name, flags, mode);
    if (IS_ERR_VALUE(file))
      return PTR_ERR(file);

    int fd = file_dup(file);
    if (fd < 0) {
      file_decref(file);
      return -ENOMEM;
    }

    return fd;
  }
  return -EBADF;
}
Exemple #2
0
int sys_openat(int dirfd, const char* name, int flags, int mode)
{
  if(name[0] == '/'){
    return sys_open(name, flags, mode);
  }
  file_t* dir = file_get(dirfd);
  if(dir)
  {
    file_t* file = file_openat(dir->kfd, name, flags, mode);
    if (IS_ERR_VALUE(file))
      return PTR_ERR(file);

    int fd = file_dup(file);
    if (fd < 0)
      return -ENOMEM;

    return fd;
   }
  return -EBADF;
}
Exemple #3
0
file_t* file_open(const char* fn, int flags)
{
  return file_openat(AT_FDCWD, fn, flags);
}