/* * Prescan command line for [-S server] [-U user] arguments * and fill li structure with defaults */ int ncp_li_init(struct ncp_conn_loginfo *li, int argc, char *argv[]) { int opt, error = 0; char *arg; bzero(li,sizeof(*li)); li->timeout = 15; /* these values should be large enough to handle */ li->retry_count = 4; /* slow servers, even on ethernet */ li->access_mode = 0; li->password = NULL; li->sig_level = 1; li->objtype = NCP_BINDERY_USER; li->owner = NCP_DEFAULT_OWNER; li->group = NCP_DEFAULT_GROUP; server_name = NULL; if (argv == NULL) return 0; while (error == 0 && (opt = ncp_getopt(argc, argv, ":S:U:")) != -1) { arg = ncp_optarg; switch (opt) { case 'S': error = ncp_li_setserver(li, arg); break; case 'U': error = ncp_li_setuser(li, arg); break; } } ncp_optind = ncp_optreset = 1; return error; }
static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options) { int optval; char *optarg; unsigned long optint; int version = 0; int ret; data->flags = 0; data->int_flags = 0; data->mounted_uid = 0; data->wdog_pid = NULL; data->ncp_fd = ~0; data->time_out = 10; data->retry_count = 20; data->uid = 0; data->gid = 0; data->file_mode = 0600; data->dir_mode = 0700; data->info_fd = -1; data->mounted_vol[0] = 0; while ((optval = ncp_getopt("ncpfs", &options, ncp_opts, NULL, &optarg, &optint)) != 0) { ret = optval; if (ret < 0) goto err; switch (optval) { case 'u': data->uid = optint; break; case 'g': data->gid = optint; break; case 'o': data->mounted_uid = optint; break; case 'm': data->file_mode = optint; break; case 'd': data->dir_mode = optint; break; case 't': data->time_out = optint; break; case 'r': data->retry_count = optint; break; case 'f': data->flags = optint; break; case 'w': data->wdog_pid = find_get_pid(optint); break; case 'n': data->ncp_fd = optint; break; case 'i': data->info_fd = optint; break; case 'v': ret = -ECHRNG; if (optint < NCP_MOUNT_VERSION_V4) goto err; if (optint > NCP_MOUNT_VERSION_V5) goto err; version = optint; break; } } return 0; err: put_pid(data->wdog_pid); data->wdog_pid = NULL; return ret; }
static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options) { int optval; char *optarg; unsigned long optint; int version = 0; int ret; data->flags = 0; data->int_flags = 0; data->mounted_uid = GLOBAL_ROOT_UID; data->wdog_pid = NULL; data->ncp_fd = ~0; data->time_out = NCP_DEFAULT_TIME_OUT; data->retry_count = NCP_DEFAULT_RETRY_COUNT; data->uid = GLOBAL_ROOT_UID; data->gid = GLOBAL_ROOT_GID; data->file_mode = NCP_DEFAULT_FILE_MODE; data->dir_mode = NCP_DEFAULT_DIR_MODE; data->info_fd = -1; data->mounted_vol[0] = 0; while ((optval = ncp_getopt("ncpfs", &options, ncp_opts, NULL, &optarg, &optint)) != 0) { ret = optval; if (ret < 0) goto err; switch (optval) { case 'u': data->uid = make_kuid(current_user_ns(), optint); if (!uid_valid(data->uid)) { ret = -EINVAL; goto err; } break; case 'g': data->gid = make_kgid(current_user_ns(), optint); if (!gid_valid(data->gid)) { ret = -EINVAL; goto err; } break; case 'o': data->mounted_uid = make_kuid(current_user_ns(), optint); if (!uid_valid(data->mounted_uid)) { ret = -EINVAL; goto err; } break; case 'm': data->file_mode = optint; break; case 'd': data->dir_mode = optint; break; case 't': data->time_out = optint; break; case 'r': data->retry_count = optint; break; case 'f': data->flags = optint; break; case 'w': data->wdog_pid = find_get_pid(optint); break; case 'n': data->ncp_fd = optint; break; case 'i': data->info_fd = optint; break; case 'v': ret = -ECHRNG; if (optint < NCP_MOUNT_VERSION_V4) goto err; if (optint > NCP_MOUNT_VERSION_V5) goto err; version = optint; break; } } return 0; err: put_pid(data->wdog_pid); data->wdog_pid = NULL; return ret; }