Exemple #1
0
int
sc_ftruncate(thread_t *t, syscall_result_t *r, ftruncate_args_t *args)
{
    file_t *f = f_get(t->thr_proc->p_fd, args->fd);
    if(!f)
        return -EBADF;
    f_truncate(f, args->length);
    frele(f);
    return -EOK;
}
Exemple #2
0
errno_t
sc_lseek(thread_t *p, syscall_result_t *r, lseek_args *args)
{
    file_t *f = f_get(p->thr_proc->p_fd, args->fd);
    if (!f)
        return -EBADF;
    int res = f_seek(f, args->offset, args->whence);
    frele(f);
    if(res < 0)
        return res;
    r->result = res;
    return -EOK;
}
Exemple #3
0
errno_t
sc_close(thread_t *t, syscall_result_t *r, close_args *args)
{
    file_t *f = f_get(t->thr_proc->p_fd, args->fd);
    if ( f == NULL )
        return -EBADF;

    r->result = 0;
    f_set(t->thr_proc->p_fd, NULL, args->fd, FALSE);
    f_close(f); //close pozbywa się referencji -> dalsze odwoływanie się do niej
                // jest błędem
    return 0;
}
Exemple #4
0
errno_t
sc_ioctl(thread_t *t, syscall_result_t *r, sc_ioctl_args *args)
{
    file_t *file = f_get(t->thr_proc->p_fd, args->fd);
    if (file == NULL) {
        return -EBADF;
    }
    int res = f_ioctl(file, args->cmd, args->arg);
    frele(file);
    if(res < 0)
        return res;
    r->result = res;
    return -EOK;
}
Exemple #5
0
errno_t
sc_isatty(thread_t *t, syscall_result_t *r, sc_isatty_args *args)
{
    r->result = 0;
    file_t *file = f_get(t->thr_proc->p_fd, args->fd);
    if (file == NULL) {
        return -EBADF;
    }
    if(!vnode_isatty(file->f_vnode)) {
        frele(file);
        return -ENOTTY;
    }
    frele(file);
    r->result = 1;    
    return -EOK;
}
Exemple #6
0
const exprt qbf_squolem_coret::f_get_dnf(WitnessStack *wsp)
{
  Clause *p=wsp->posWits;

  if(!p) return exprt(ID_false, typet(ID_bool));

  exprt::operandst operands;

  while(p!=NULL)
  {
    exprt cube=and_exprt();

    for(unsigned i=0; i<p->size; i++)
    {
      const Literal &lit=p->literals[i];
      exprt subf = f_get(literalt(var(lit), !isPositive(lit)));
      if(find(cube.operands().begin(), cube.operands().end(), subf)==
         cube.operands().end())
        cube.move_to_operands(subf);

      simplify_extractbits(cube);
    }

    if(cube.operands().empty())
      cube=true_exprt();
    else if(cube.operands().size()==1)
    {
      const exprt tmp=cube.op0();
      cube=tmp;
    }

    #if 0
    std::cout << "CUBE: " << cube << std::endl;
    #endif

    operands.push_back(cube);

    p=p->next;
  }

  return or_exprt(operands);
}
Exemple #7
0
const exprt qbf_squolem_coret::f_get_cnf(WitnessStack *wsp)
{
  Clause *p=wsp->negWits;

  if(!p) return exprt(ID_true, typet(ID_bool));

  exprt::operandst operands;

  while(p!=NULL)
  {
    exprt clause=or_exprt();

    for(unsigned i=0; i<p->size; i++)
    {
      const Literal &lit=p->literals[i];
      exprt subf = f_get(literalt(var(lit), isPositive(lit))); // negated!
      if(find(clause.operands().begin(), clause.operands().end(), subf)==
         clause.operands().end())
        clause.move_to_operands(subf);
    }

    if(clause.operands().empty())
      clause=false_exprt();
    else if(clause.operands().size()==1)
    {
      const exprt tmp=clause.op0();
      clause=tmp;
    }

    #if 0
    std::cout << "CLAUSE: " << clause << std::endl;
    #endif

    operands.push_back(clause);

    p=p->next;
  }

  return and_exprt(operands);
}