Exemplo n.º 1
0
int main(int argc, char *argv[]) {
        int r = 0;

        if (argc > 1 && argc != 4) {
                log_error("This program takes three or no arguments.");
                return EXIT_FAILURE;
        }

        if (argc > 1)
                arg_dest = argv[1];

        log_set_prohibit_ipc(true);
        log_set_target(LOG_TARGET_AUTO);
        log_parse_environment();
        log_open();

        umask(0022);

        /* Don't even consider resuming outside of initramfs. */
        if (!in_initrd())
                return EXIT_SUCCESS;

        r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0);
        if (r < 0)
                log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

        r = process_resume();
        free(arg_resume_device);

        return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
Exemplo n.º 2
0
static void * process_command_thread(void * other)
{

	struct fuse_client * c = other;
	int ret=0;
	char tosend[sizeof(struct afp_server_response) + MAX_CLIENT_RESPONSE];
	struct afp_server_response response;


	switch(c->incoming_string[0]) {
	case AFP_SERVER_COMMAND_MOUNT: 
		ret=process_mount(c);
		break;
	case AFP_SERVER_COMMAND_STATUS: 
		ret=process_status(c);
		break;
	case AFP_SERVER_COMMAND_UNMOUNT: 
		ret=process_unmount(c);
		break;
	case AFP_SERVER_COMMAND_SUSPEND: 
		ret=process_suspend(c);
		break;
	case AFP_SERVER_COMMAND_RESUME: 
		ret=process_resume(c);
		break;
	case AFP_SERVER_COMMAND_PING: 
		ret=process_ping(c);
		break;
	case AFP_SERVER_COMMAND_EXIT: 
		ret=process_exit(c);
		break;
	default:
		log_for_client((void *)c,AFPFSD,LOG_ERR,"Unknown command\n");
	}
	/* Send response */
	response.result=ret;
	response.len=strlen(c->client_string);

	bcopy(&response,tosend,sizeof(response));
	bcopy(c->client_string,tosend+sizeof(response),response.len);
	ret=write(c->fd,tosend,sizeof(response)+response.len);
	if (ret<0) {
		perror("Writing");
	}

	if ((!c) || (c->fd==0)) return NULL;
	rm_fd_and_signal(c->fd);
	close(c->fd);
	remove_client(c);

	return NULL;

}
Exemplo n.º 3
0
void UDCIintHandler(void* pparam)
{
	u32_t int2flgReg = readw( UDC_INTFLG );

	// USB Bus Status Interrupt
	if ( int2flgReg & VBUS_INTR ) {			// VBUS interrupt
		process_vbus_intr();
	}

	if ( int2flgReg & USBRST_INTR ) {		// USB Bus reset
		process_reset();
	}

	if ( int2flgReg & SETUP_INTR ) {		// Setup request inetrrupt
		process_setup_req();
	}

	if ( int2flgReg & SUSP_INTR ) {			// Bus suspend interrupt
		process_suspend();
	}

	if ( int2flgReg & RSUME_INTR ) {		// Bus resume interrupt
		process_resume();
	}

	// Control Endpoint Interrupt
	if ( int2flgReg & IN0_INTR ) {
		process_in0();
	}
	if ( int2flgReg & OUT0_INTR ) {
		process_out0();
	}

	// Bulk_OUT Interrupt
	if ( int2flgReg & ENP1_INTR ) {
		process_bulk_out(0);
	}
//#if END_POINTER_NUM == 16
	if ( int2flgReg & ENP4_INTR ) {
		process_bulk_out(1);
	}
	if ( int2flgReg & ENP7_INTR ) {
		process_bulk_out(2);
	}
	if ( int2flgReg & ENP10_INTR ) {
		process_bulk_out(3);
	}
	if ( int2flgReg & ENP13_INTR ) {
		process_bulk_out(4);
	}
//#endif	/* END_POINTER_NUM */

	// Bulk_IN Interrupt
	if ( int2flgReg & ENP2_INTR ) {
		process_bulk_in(0);
	}
//#if END_POINTER_NUM == 16
	if ( int2flgReg & ENP5_INTR ) {
		process_bulk_in(1);
	}
	if ( int2flgReg & ENP8_INTR ) {
		process_bulk_in(2);
	}
	if ( int2flgReg & ENP11_INTR ) {
		process_bulk_in(3);
	}
	if ( int2flgReg & ENP14_INTR ) {
		process_bulk_in(4);
	}
//#endif	/* END_POINTER_NUM */

	// Intr_IN Interrupt
	if ( int2flgReg & ENP3_INTR ) {
		process_intr_req(0);
	}
//#if END_POINTER_NUM == 16
	if ( int2flgReg & ENP6_INTR ) {
		process_intr_req(1);
	}
	if ( int2flgReg & ENP9_INTR ) {
		process_intr_req(2);
	}
	if ( int2flgReg & ENP12_INTR ) {
		process_intr_req(3);
	}
	if ( int2flgReg & ENP15_INTR ) {
		process_intr_req(4);
	}
//#endif	/* END_POINTER_NUM */
}