Lines Matching +full:integer +full:- +full:n
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com>
36 /* Options that take integer arguments */
72 int version = -EINVAL; in get_cache_mode()
76 p9_debug(P9_DEBUG_9P, "Cache mode: loose\n"); in get_cache_mode()
79 p9_debug(P9_DEBUG_9P, "Cache mode: fscache\n"); in get_cache_mode()
82 p9_debug(P9_DEBUG_9P, "Cache mode: mmap\n"); in get_cache_mode()
85 p9_debug(P9_DEBUG_9P, "Cache mode: readahead\n"); in get_cache_mode()
88 p9_debug(P9_DEBUG_9P, "Cache mode: none\n"); in get_cache_mode()
90 version = -EINVAL; in get_cache_mode()
91 pr_info("Unknown Cache mode or invalid value %s\n", s); in get_cache_mode()
101 struct v9fs_session_info *v9ses = root->d_sb->s_fs_info; in v9fs_show_options()
103 if (v9ses->debug) in v9fs_show_options()
104 seq_printf(m, ",debug=%x", v9ses->debug); in v9fs_show_options()
105 if (!uid_eq(v9ses->dfltuid, V9FS_DEFUID)) in v9fs_show_options()
107 from_kuid_munged(&init_user_ns, v9ses->dfltuid)); in v9fs_show_options()
108 if (!gid_eq(v9ses->dfltgid, V9FS_DEFGID)) in v9fs_show_options()
110 from_kgid_munged(&init_user_ns, v9ses->dfltgid)); in v9fs_show_options()
111 if (v9ses->afid != ~0) in v9fs_show_options()
112 seq_printf(m, ",afid=%u", v9ses->afid); in v9fs_show_options()
113 if (strcmp(v9ses->uname, V9FS_DEFUSER) != 0) in v9fs_show_options()
114 seq_printf(m, ",uname=%s", v9ses->uname); in v9fs_show_options()
115 if (strcmp(v9ses->aname, V9FS_DEFANAME) != 0) in v9fs_show_options()
116 seq_printf(m, ",aname=%s", v9ses->aname); in v9fs_show_options()
117 if (v9ses->nodev) in v9fs_show_options()
119 if (v9ses->cache) in v9fs_show_options()
120 seq_printf(m, ",cache=%x", v9ses->cache); in v9fs_show_options()
122 if (v9ses->cachetag && (v9ses->cache & CACHE_FSCACHE)) in v9fs_show_options()
123 seq_printf(m, ",cachetag=%s", v9ses->cachetag); in v9fs_show_options()
126 switch (v9ses->flags & V9FS_ACCESS_MASK) { in v9fs_show_options()
138 from_kuid_munged(&init_user_ns, v9ses->uid)); in v9fs_show_options()
142 if (v9ses->flags & V9FS_IGNORE_QV) in v9fs_show_options()
144 if (v9ses->flags & V9FS_DIRECT_IO) in v9fs_show_options()
146 if (v9ses->flags & V9FS_POSIX_ACL) in v9fs_show_options()
149 if (v9ses->flags & V9FS_NO_XATTR) in v9fs_show_options()
152 return p9_show_client_options(m, v9ses->clnt); in v9fs_show_options()
156 * v9fs_parse_options - parse mount options into session structure
160 * Return 0 upon success, -ERRNO upon failure.
173 v9ses->afid = ~0; in v9fs_parse_options()
174 v9ses->debug = 0; in v9fs_parse_options()
175 v9ses->cache = CACHE_NONE; in v9fs_parse_options()
177 v9ses->cachetag = NULL; in v9fs_parse_options()
179 v9ses->session_lock_timeout = P9_LOCK_TIMEOUT; in v9fs_parse_options()
186 ret = -ENOMEM; in v9fs_parse_options()
203 "integer field, but no integer?\n"); in v9fs_parse_options()
206 v9ses->debug = option; in v9fs_parse_options()
217 "integer field, but no integer?\n"); in v9fs_parse_options()
221 v9ses->dfltuid = make_kuid(current_user_ns(), option); in v9fs_parse_options()
222 if (!uid_valid(v9ses->dfltuid)) { in v9fs_parse_options()
224 "uid field, but not a uid?\n"); in v9fs_parse_options()
225 ret = -EINVAL; in v9fs_parse_options()
232 "integer field, but no integer?\n"); in v9fs_parse_options()
236 v9ses->dfltgid = make_kgid(current_user_ns(), option); in v9fs_parse_options()
237 if (!gid_valid(v9ses->dfltgid)) { in v9fs_parse_options()
239 "gid field, but not a gid?\n"); in v9fs_parse_options()
240 ret = -EINVAL; in v9fs_parse_options()
247 "integer field, but no integer?\n"); in v9fs_parse_options()
250 v9ses->afid = option; in v9fs_parse_options()
254 kfree(v9ses->uname); in v9fs_parse_options()
255 v9ses->uname = match_strdup(&args[0]); in v9fs_parse_options()
256 if (!v9ses->uname) { in v9fs_parse_options()
257 ret = -ENOMEM; in v9fs_parse_options()
262 kfree(v9ses->aname); in v9fs_parse_options()
263 v9ses->aname = match_strdup(&args[0]); in v9fs_parse_options()
264 if (!v9ses->aname) { in v9fs_parse_options()
265 ret = -ENOMEM; in v9fs_parse_options()
270 v9ses->nodev = 1; in v9fs_parse_options()
273 v9ses->flags |= V9FS_NO_XATTR; in v9fs_parse_options()
276 v9ses->flags |= V9FS_DIRECT_IO; in v9fs_parse_options()
279 v9ses->flags |= V9FS_IGNORE_QV; in v9fs_parse_options()
283 kfree(v9ses->cachetag); in v9fs_parse_options()
284 v9ses->cachetag = match_strdup(&args[0]); in v9fs_parse_options()
285 if (!v9ses->cachetag) { in v9fs_parse_options()
286 ret = -ENOMEM; in v9fs_parse_options()
294 ret = -ENOMEM; in v9fs_parse_options()
296 "problem allocating copy of cache arg\n"); in v9fs_parse_options()
303 v9ses->cache = r; in v9fs_parse_options()
311 ret = -ENOMEM; in v9fs_parse_options()
313 "problem allocating copy of access arg\n"); in v9fs_parse_options()
317 v9ses->flags &= ~V9FS_ACCESS_MASK; in v9fs_parse_options()
319 v9ses->flags |= V9FS_ACCESS_USER; in v9fs_parse_options()
321 v9ses->flags |= V9FS_ACCESS_ANY; in v9fs_parse_options()
323 v9ses->flags |= V9FS_ACCESS_CLIENT; in v9fs_parse_options()
327 v9ses->flags |= V9FS_ACCESS_SINGLE; in v9fs_parse_options()
331 pr_info("Unknown access argument %s: %d\n", in v9fs_parse_options()
336 v9ses->uid = make_kuid(current_user_ns(), uid); in v9fs_parse_options()
337 if (!uid_valid(v9ses->uid)) { in v9fs_parse_options()
338 ret = -EINVAL; in v9fs_parse_options()
339 pr_info("Unknown uid %s\n", s); in v9fs_parse_options()
348 v9ses->flags |= V9FS_POSIX_ACL; in v9fs_parse_options()
351 "Not defined CONFIG_9P_FS_POSIX_ACL. Ignoring posixacl option\n"); in v9fs_parse_options()
359 "integer field, but no integer?\n"); in v9fs_parse_options()
365 "locktimeout must be a greater than zero integer.\n"); in v9fs_parse_options()
366 ret = -EINVAL; in v9fs_parse_options()
369 v9ses->session_lock_timeout = (long)option * HZ; in v9fs_parse_options()
384 * v9fs_session_init - initialize session
395 int rc = -ENOMEM; in v9fs_session_init()
397 v9ses->uname = kstrdup(V9FS_DEFUSER, GFP_KERNEL); in v9fs_session_init()
398 if (!v9ses->uname) in v9fs_session_init()
401 v9ses->aname = kstrdup(V9FS_DEFANAME, GFP_KERNEL); in v9fs_session_init()
402 if (!v9ses->aname) in v9fs_session_init()
404 init_rwsem(&v9ses->rename_sem); in v9fs_session_init()
406 v9ses->uid = INVALID_UID; in v9fs_session_init()
407 v9ses->dfltuid = V9FS_DEFUID; in v9fs_session_init()
408 v9ses->dfltgid = V9FS_DEFGID; in v9fs_session_init()
410 v9ses->clnt = p9_client_create(dev_name, data); in v9fs_session_init()
411 if (IS_ERR(v9ses->clnt)) { in v9fs_session_init()
412 rc = PTR_ERR(v9ses->clnt); in v9fs_session_init()
413 p9_debug(P9_DEBUG_ERROR, "problem initializing 9p client\n"); in v9fs_session_init()
417 v9ses->flags = V9FS_ACCESS_USER; in v9fs_session_init()
419 if (p9_is_proto_dotl(v9ses->clnt)) { in v9fs_session_init()
420 v9ses->flags = V9FS_ACCESS_CLIENT; in v9fs_session_init()
421 v9ses->flags |= V9FS_PROTO_2000L; in v9fs_session_init()
422 } else if (p9_is_proto_dotu(v9ses->clnt)) { in v9fs_session_init()
423 v9ses->flags |= V9FS_PROTO_2000U; in v9fs_session_init()
430 v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ; in v9fs_session_init()
433 ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)) { in v9fs_session_init()
438 v9ses->flags &= ~V9FS_ACCESS_MASK; in v9fs_session_init()
439 v9ses->flags |= V9FS_ACCESS_USER; in v9fs_session_init()
444 ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) { in v9fs_session_init()
446 v9ses->flags &= ~V9FS_ACCESS_MASK; in v9fs_session_init()
447 v9ses->flags |= V9FS_ACCESS_ANY; in v9fs_session_init()
448 v9ses->uid = INVALID_UID; in v9fs_session_init()
451 !((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)) { in v9fs_session_init()
456 v9ses->flags &= ~V9FS_ACL_MASK; in v9fs_session_init()
459 fid = p9_client_attach(v9ses->clnt, NULL, v9ses->uname, INVALID_UID, in v9fs_session_init()
460 v9ses->aname); in v9fs_session_init()
463 p9_debug(P9_DEBUG_ERROR, "cannot attach\n"); in v9fs_session_init()
467 if ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_SINGLE) in v9fs_session_init()
468 fid->uid = v9ses->uid; in v9fs_session_init()
470 fid->uid = INVALID_UID; in v9fs_session_init()
474 if (v9ses->cache & CACHE_FSCACHE) { in v9fs_session_init()
481 list_add(&v9ses->slist, &v9fs_sessionlist); in v9fs_session_init()
488 kfree(v9ses->cachetag); in v9fs_session_init()
490 p9_client_destroy(v9ses->clnt); in v9fs_session_init()
492 kfree(v9ses->uname); in v9fs_session_init()
493 kfree(v9ses->aname); in v9fs_session_init()
498 * v9fs_session_close - shutdown a session
505 if (v9ses->clnt) { in v9fs_session_close()
506 p9_client_destroy(v9ses->clnt); in v9fs_session_close()
507 v9ses->clnt = NULL; in v9fs_session_close()
512 kfree(v9ses->cachetag); in v9fs_session_close()
514 kfree(v9ses->uname); in v9fs_session_close()
515 kfree(v9ses->aname); in v9fs_session_close()
518 list_del(&v9ses->slist); in v9fs_session_close()
523 * v9fs_session_cancel - terminate a session
531 p9_debug(P9_DEBUG_ERROR, "cancel session %p\n", v9ses); in v9fs_session_cancel()
532 p9_client_disconnect(v9ses->clnt); in v9fs_session_cancel()
536 * v9fs_session_begin_cancel - Begin terminate of a session
544 p9_debug(P9_DEBUG_ERROR, "begin cancel session %p\n", v9ses); in v9fs_session_begin_cancel()
545 p9_client_begin_disconnect(v9ses->clnt); in v9fs_session_begin_cancel()
558 ssize_t n = 0, count = 0, limit = PAGE_SIZE; in caches_show() local
563 if (v9ses->cachetag) { in caches_show()
564 n = snprintf(buf, limit, "%s\n", v9ses->cachetag); in caches_show()
565 if (n < 0) { in caches_show()
566 count = n; in caches_show()
570 count += n; in caches_show()
571 limit -= n; in caches_show()
594 * v9fs_sysfs_init - Initialize the v9fs sysfs interface
602 return -ENOMEM; in v9fs_sysfs_init()
606 return -ENOMEM; in v9fs_sysfs_init()
613 * v9fs_sysfs_cleanup - Unregister the v9fs sysfs interface
627 memset(&v9inode->qid, 0, sizeof(v9inode->qid)); in v9fs_inode_init_once()
628 inode_init_once(&v9inode->netfs.inode); in v9fs_inode_init_once()
632 * v9fs_init_inode_cache - initialize a cache for 9P
643 return -ENOMEM; in v9fs_init_inode_cache()
649 * v9fs_destroy_inode_cache - destroy the cache of 9P inode
678 * init_v9fs - Initialize module
686 pr_info("Installing v9fs 9p2000 file system support\n"); in init_v9fs()
691 pr_err("Failed to register v9fs for caching\n"); in init_v9fs()
697 pr_err("Failed to register with sysfs\n"); in init_v9fs()
702 pr_err("Failed to register filesystem\n"); in init_v9fs()
718 * exit_v9fs - shutdown module