Пример #1
0
static int handle(const char *name, umode_t mode, struct device *dev)
{
    if (mode)
        return handle_create(name, mode, dev);
    else
        return handle_remove(name, dev);
}
Пример #2
0
int main(int argc, char** argv) {
    int retval = config.parse_file();
    if (retval) {
        fprintf(stderr, "can't parse config file\n");
        exit(1);
    }
    retval = boinc_db.open(
        config.db_name, config.db_host, config.db_user, config.db_passwd
    );
    if (retval) {
        fprintf(stderr, "can't open DB\n");
        exit(1);
    }
    for (int i=1; i<argc; i++) {
        if (!strcmp(argv[i], "add")) {
            if (argc != 3) usage();
            retval = handle_add(argv[++i]);
            if (retval) {
                fprintf(stderr, "error %d\n", retval);
            } else {
                printf("file added successfully\n");
            }
            exit(retval);
        }
        if (!strcmp(argv[i], "remove")) {
            if (argc != 3) usage();
            retval = handle_remove(argv[++i]);
            if (retval) {
                fprintf(stderr, "error %d\n", retval);
            } else {
                printf("file removed successfully\n");
            }
            exit(retval);
        }
        if (!strcmp(argv[i], "retrieve")) {
            if (argc != 3) usage();
            retval = handle_retrieve(argv[++i]);
            if (retval) {
                fprintf(stderr, "error %d\n", retval);
            } else {
                printf("file retrieval started\n");
            }
            exit(retval);
        }
        if (!strcmp(argv[i], "status")) {
            if (argc != 3) usage();
            retval = handle_status(argv[++i]);
            if (retval) {
                fprintf(stderr, "error %d\n", retval);
            }
            exit(retval);
        }
        usage();
    }
    usage();
}
Пример #3
0
void
purple_socket_destroy(PurpleSocket *ps)
{
	if (ps == NULL)
		return;

	handle_remove(ps);

	purple_socket_cancel(ps);

	g_free(ps->host);
	g_hash_table_destroy(ps->data);
	g_free(ps);
}
Пример #4
0
/*
 * System call handler
 *
 * retrieves system call number from user space
 * and invokes the requested method
 */
static void
syscall_handler (struct intr_frame *f)
{

        /* retrieve system call number
        and switch to corresponding method */
        unsigned int syscall_number = *((unsigned int*) syscall_get_kernel_address(f->esp));

        switch(syscall_number)
        {
                /* process system calls */
                case SYS_HALT:
                        handle_halt(f);
                        break;

                case SYS_EXIT:
                        handle_exit(f);
                        break;

                case SYS_EXEC:
                        handle_exec(f);
                        break;

                case SYS_WAIT:
                        handle_wait(f);
                        break;

                /* file system calls */
                case SYS_CREATE:
                        handle_create(f);
                        break;
 
                case SYS_REMOVE:
                        handle_remove(f);
                        break;

                case SYS_OPEN:
                        handle_open(f);
                        break;

                case SYS_FILESIZE:
                        handle_filesize(f);
                        break;

                case SYS_READ:
                        handle_read(f);
                        break;

                case SYS_WRITE:
                        handle_write(f);
                        break;

                case SYS_SEEK:
                        handle_seek(f);
                        break;

                case SYS_TELL:
                        handle_tell(f);
                        break;

                case SYS_CLOSE:
                        handle_close(f);
                        break;

                case SYS_CHDIR:
                        handle_chdir(f);
                        break;

                case SYS_MKDIR:
                        handle_mkdir(f);
                        break;

                case SYS_READDIR:
                        handle_readdir(f);
                        break;

                case SYS_ISDIR:
                        handle_isdir(f);
                        break;

                case SYS_INUMBER:
                        handle_inumber(f);
                        break;

                default: /* SYSCALL_ERROR: */
                        handle_no_such_syscall(f);
                        break;
        }
}
Пример #5
0
int main(int argc, char *argv[])
{
    int i;
    int res = 1;
    int cmd = CMD_NONE;
    int stdout_fd;
    char footer_location[256];
    struct fstab *fstab;
    struct fstab_part *p;
    char *argument = NULL;

    klog_init();

    // output all messages to dmesg,
    // but it is possible to filter out INFO messages
    klog_set_level(6);

    mrom_set_log_tag("trampoline_encmnt");
    mrom_set_dir("/mrom_enc/");

    for(i = 1; i < argc; ++i)
    {
        if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
        {
            print_help(argv);
            return 0;
        }
        else if(cmd == CMD_NONE)
        {
            if(strcmp(argv[i], "decrypt") == 0)
                cmd = CMD_DECRYPT;
            else if(strcmp(argv[i], "remove") == 0)
                cmd = CMD_REMOVE;
            else if(strcmp(argv[i], "pwtype") == 0)
                cmd = CMD_PWTYPE;
        }
        else if(!argument)
        {
            argument = argv[i];
        }
    }

    if(argc == 1 || cmd == CMD_NONE)
    {
        print_help(argv);
        return 0;
    }

    fstab = fstab_auto_load();
    if(!fstab)
    {
        ERROR("Failed to load fstab!");
        return 1;
    }

    p = fstab_find_first_by_path(fstab, "/data");
    if(!p)
    {
        ERROR("Failed to find /data partition in fstab\n");
        goto exit;
    }

    strcpy(footer_location, "");

    if(p->options != NULL && get_footer_from_opts(footer_location,
            sizeof(footer_location), p->options) < 0)
        goto exit;

    if(p->options2 != NULL && strcmp(footer_location, "") == 0 &&
            get_footer_from_opts(footer_location, sizeof(footer_location),
            p->options2) < 0)
        goto exit;

    INFO("Setting encrypted partition data to %s %s %s\n", p->device, footer_location, p->type);
    set_partition_data(p->device, footer_location, p->type);

    // cryptfs prints informations, we don't want that
    stdout_fd = dup(1);
    freopen("/dev/null", "ae", stdout);

    switch(cmd)
    {
        case CMD_PWTYPE:
            if(handle_pwtype(stdout_fd) < 0)
                goto exit;
            break;
        case CMD_DECRYPT:
            if(handle_decrypt(stdout_fd, argument) < 0)
                goto exit;
            break;
        case CMD_REMOVE:
            if(handle_remove() < 0)
                goto exit;
            break;
    }

    res = 0;
exit:
    fstab_destroy(fstab);
    return res;
}