Example #1
0
int user_after_syscall(void *cpu_env, bitmask_transtbl *fcntl_flags_tbl,
                       int num, abi_long arg1, abi_long arg2, abi_long arg3,
                       abi_long arg4, abi_long arg5, abi_long arg6,
                       abi_long arg7, abi_long arg8, void *p, abi_long ret){
    switch (num){
        case TARGET_NR_read:
            user_read(ret, arg1, p);
            break;
        case TARGET_NR_write:
            user_write(ret, arg1, p);
            break;
        case TARGET_NR_open:
            user_open(fcntl_flags_tbl, ret, p, arg2);
            break;
        case TARGET_NR_openat:
            user_open(fcntl_flags_tbl, ret, p, arg3);
            break;
        case TARGET_NR_creat:
            user_creat(ret, p);
            break;
        default:
            break;
    }
    return 0;
}
int ComprDataIO::Read( void* p, int n )
{
	unrar_err_t err = user_read( user_read_data, p, &n, Tell_ );
	if ( err )
		ReportError( err );
	
	Tell_ += n;
	if ( Tell_ < 0 )
		ReportError( unrar_err_huge );
	
	return n;
}
Example #3
0
int	read_state(t_server *server, t_client *client)
{
  user_read(server, client);
  return (0);
}
Example #4
0
/**
 * @ingroup shell
 *
 * Take a system call number and run that system call.  This is only for
 * demonstration.
 * @param nargs number of arguments
 * @param args  array of arguments
 * @return non-zero value on error
 */
shellcmd xsh_user(int nargs, char **args)
{
    static mailbox mybox;
    int call_num;
    char buffer[BUF_LENGTH];

    if (nargs != 2)
    {
        printf("Insufficient arguments.\n");
        printf("Try again later.\n");
        return 1;
    }

    call_num = atoi(args[1]);

    switch (call_num)
    {
    case 0:
        user_none();
        break;
    case 1:
        user_yield();
        break;
    case 2:
        user_sleep(4000);
        break;
    case 3:
        user_kill(5);           // pick a better number
        break;
    case 4:
        user_open(LOOP, 0);
        break;
    case 5:
        user_control(LOOP, 0, 1, 2);
        break;
    case 6:
        sprintf(buffer, "Process %d\n", gettid());
        user_write(LOOP, buffer, BUF_LENGTH);
        break;
    case 7:
        user_read(LOOP, buffer, BUF_LENGTH);
        printf("%s\n", buffer);
        break;
    case 8:
        user_putc(LOOP, 'm');
        break;
    case 9:
        printf("%c\n", user_getc(LOOP));
        break;
    case 10:
        user_seek(LOOP, 5);
        break;
    case 11:
        user_close(LOOP);
        break;
    case 12:
        printf("%d\n", user_getdev("LOOP"));
        break;
    case 13:
        mybox = user_mboxalloc(50);
        printf("Mailbox %d assigned.\n", mybox);
        break;
    case 14:
        user_mboxfree(mybox);
        break;
    case 15:
        user_mboxsend(mybox, 0xa5a5a5a5);
        break;
    case 16:
        printf("0x%08x\n", user_mboxrecv(mybox));
        break;
    default:
        printf("No corresponding call.\n");
    }

    return 0;
}