Lines Matching refs:ctx

199 cifs_parse_security_flavors(struct fs_context *fc, char *value, struct smb3_fs_context *ctx)
208 ctx->sectype = Unspecified;
209 ctx->sign = false;
216 ctx->sign = true;
219 ctx->sectype = Kerberos;
222 ctx->sign = true;
225 ctx->sectype = RawNTLMSSP;
228 ctx->sign = true;
231 ctx->sectype = NTLMv2;
234 ctx->nullauth = 1;
235 kfree(ctx->username);
236 ctx->username = NULL;
256 cifs_parse_cache_flavor(struct fs_context *fc, char *value, struct smb3_fs_context *ctx)
262 ctx->direct_io = false;
263 ctx->strict_io = false;
264 ctx->cache_ro = false;
265 ctx->cache_rw = false;
268 ctx->direct_io = false;
269 ctx->strict_io = true;
270 ctx->cache_ro = false;
271 ctx->cache_rw = false;
274 ctx->direct_io = true;
275 ctx->strict_io = false;
276 ctx->cache_ro = false;
277 ctx->cache_rw = false;
280 ctx->direct_io = false;
281 ctx->strict_io = false;
282 ctx->cache_ro = true;
283 ctx->cache_rw = false;
286 ctx->direct_io = false;
287 ctx->strict_io = false;
288 ctx->cache_ro = false;
289 ctx->cache_rw = true;
300 if (ctx->field) { \
301 new_ctx->field = kstrdup(ctx->field, GFP_ATOMIC); \
310 smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx)
312 memcpy(new_ctx, ctx, sizeof(*ctx));
341 cifs_parse_smb_version(struct fs_context *fc, char *value, struct smb3_fs_context *ctx, bool is_smb3)
357 ctx->ops = &smb1_operations;
358 ctx->vals = &smb1_values;
369 ctx->ops = &smb20_operations;
370 ctx->vals = &smb20_values;
381 ctx->ops = &smb21_operations;
382 ctx->vals = &smb21_values;
385 ctx->ops = &smb30_operations;
386 ctx->vals = &smb30_values;
389 ctx->ops = &smb30_operations; /* currently identical with 3.0 */
390 ctx->vals = &smb302_values;
393 ctx->ops = &smb311_operations;
394 ctx->vals = &smb311_values;
397 ctx->ops = &smb30_operations; /* currently identical with 3.0 */
398 ctx->vals = &smb3any_values;
401 ctx->ops = &smb30_operations;
402 ctx->vals = &smbdefault_values;
488 * Return full path based on the values of @ctx->{UNC,prepath}.
492 char *smb3_fs_context_fullpath(const struct smb3_fs_context *ctx, char dirsep)
497 ulen = strlen(ctx->UNC);
498 plen = ctx->prepath ? strlen(ctx->prepath) + 1 : 0;
503 memcpy(s, ctx->UNC, ulen);
506 memcpy(s + ulen + 1, ctx->prepath, plen);
514 * Parse a devname into substrings and populate the ctx->UNC and ctx->prepath
519 smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
542 kfree(ctx->server_hostname);
543 ctx->server_hostname = kstrndup(devname + 2, pos - devname - 2, GFP_KERNEL);
544 if (!ctx->server_hostname)
557 kfree(ctx->UNC);
558 ctx->UNC = kstrndup(devname, pos - devname, GFP_KERNEL);
559 if (!ctx->UNC)
562 convert_delimiter(ctx->UNC, '\\');
568 kfree(ctx->prepath);
569 ctx->prepath = NULL;
575 ctx->prepath = cifs_sanitize_prepath(pos, GFP_KERNEL);
576 if (IS_ERR(ctx->prepath)) {
577 rc = PTR_ERR(ctx->prepath);
578 ctx->prepath = NULL;
604 * @ctx: The superblock configuration to fill in.
669 struct smb3_fs_context *ctx = smb3_fc2context(fc);
671 if (ctx->rdma && ctx->vals->protocol_id < SMB30_PROT_ID) {
678 if (ctx->multiuser) {
684 if (ctx->got_version == false)
688 if (!ctx->UNC) {
694 if (strlen(ctx->UNC) < 3 || !strchr(ctx->UNC + 3, '\\')) {
699 if (!ctx->got_ip) {
705 slash = strchr(&ctx->UNC[2], '\\');
706 len = slash - &ctx->UNC[2];
707 if (!cifs_convert_address((struct sockaddr *)&ctx->dstaddr,
708 &ctx->UNC[2], len)) {
715 cifs_set_port((struct sockaddr *)&ctx->dstaddr, ctx->port);
717 if (ctx->override_uid && !ctx->uid_specified) {
718 ctx->override_uid = 0;
722 if (ctx->override_gid && !ctx->gid_specified) {
723 ctx->override_gid = 0;
732 struct smb3_fs_context *ctx = smb3_fc2context(fc);
736 root = cifs_smb3_do_mount(fc->fs_type, 0, ctx);
763 struct smb3_fs_context *ctx = smb3_fc2context(fc);
765 smb3_cleanup_fs_context(ctx);
833 #define STEAL_STRING(cifs_sb, ctx, field) \
835 kfree(ctx->field); \
836 ctx->field = cifs_sb->ctx->field; \
837 cifs_sb->ctx->field = NULL; \
840 #define STEAL_STRING_SENSITIVE(cifs_sb, ctx, field) \
842 kfree_sensitive(ctx->field); \
843 ctx->field = cifs_sb->ctx->field; \
844 cifs_sb->ctx->field = NULL; \
849 struct smb3_fs_context *ctx = smb3_fc2context(fc);
859 rc = smb3_verify_reconfigure_ctx(fc, ctx, cifs_sb->ctx, need_recon);
867 * just use what we already have in cifs_sb->ctx.
869 STEAL_STRING(cifs_sb, ctx, UNC);
870 STEAL_STRING(cifs_sb, ctx, source);
871 STEAL_STRING(cifs_sb, ctx, username);
873 STEAL_STRING_SENSITIVE(cifs_sb, ctx, password);
876 ses->password = kstrdup(ctx->password, GFP_KERNEL);
878 STEAL_STRING(cifs_sb, ctx, domainname);
879 STEAL_STRING(cifs_sb, ctx, nodename);
880 STEAL_STRING(cifs_sb, ctx, iocharset);
883 if (ctx->rsize == 0)
884 ctx->rsize = cifs_sb->ctx->rsize;
885 if (ctx->wsize == 0)
886 ctx->wsize = cifs_sb->ctx->wsize;
889 smb3_cleanup_fs_context_contents(cifs_sb->ctx);
890 rc = smb3_fs_context_dup(cifs_sb->ctx, ctx);
904 struct smb3_fs_context *ctx = smb3_fc2context(fc);
930 return ctx->sloppy ? 1 : opt;
935 ctx->compression = UNKNOWN_TYPE;
940 ctx->nodfs = 1;
944 if (ctx->retry == 1)
946 ctx->retry = 0;
948 ctx->retry = 1;
952 ctx->retry = 1;
954 if (ctx->retry == 1)
956 ctx->retry = 0;
961 ctx->remap = false;
963 ctx->remap = true;
964 ctx->sfu_remap = false; /* disable SFU mapping */
969 ctx->sfu_remap = false;
971 ctx->sfu_remap = true;
972 ctx->remap = false; /* disable SFM (mapposix) mapping */
977 ctx->no_xattr = 1;
979 ctx->no_xattr = 0;
983 ctx->override_uid = 0;
985 ctx->override_uid = 1;
989 ctx->override_gid = 0;
991 ctx->override_gid = 1;
995 ctx->noperm = 1;
997 ctx->noperm = 0;
1001 ctx->dynperm = 0;
1003 ctx->dynperm = 1;
1007 ctx->sfu_emul = 0;
1009 ctx->sfu_emul = 1;
1012 ctx->noblocksnd = 1;
1015 ctx->noautotune = 1;
1018 ctx->no_lease = 1;
1021 ctx->no_sparse = 1;
1024 ctx->nodelete = 1;
1028 ctx->multichannel = false;
1029 ctx->max_channels = 1;
1031 ctx->multichannel = true;
1033 if (ctx->max_channels < 2)
1034 ctx->max_channels = 2;
1041 ctx->linux_uid = uid;
1042 ctx->uid_specified = true;
1048 ctx->cred_uid = uid;
1049 ctx->cruid_specified = true;
1055 ctx->backupuid = uid;
1056 ctx->backupuid_specified = true;
1062 ctx->backupgid = gid;
1063 ctx->backupgid_specified = true;
1069 ctx->linux_gid = gid;
1070 ctx->gid_specified = true;
1073 ctx->port = result.uint_32;
1076 ctx->file_mode = result.uint_32;
1079 ctx->dir_mode = result.uint_32;
1082 ctx->min_offload = result.uint_32;
1097 ctx->bsize = result.uint_32;
1098 ctx->got_bsize = true;
1118 ctx->rasize = result.uint_32;
1121 ctx->rsize = result.uint_32;
1122 ctx->got_rsize = true;
1125 ctx->wsize = result.uint_32;
1126 ctx->got_wsize = true;
1127 if (ctx->wsize % PAGE_SIZE != 0) {
1128 ctx->wsize = round_down(ctx->wsize, PAGE_SIZE);
1129 if (ctx->wsize == 0) {
1130 ctx->wsize = PAGE_SIZE;
1135 ctx->wsize, PAGE_SIZE);
1140 ctx->acregmax = HZ * result.uint_32;
1141 if (ctx->acregmax > CIFS_MAX_ACTIMEO) {
1147 ctx->acdirmax = HZ * result.uint_32;
1148 if (ctx->acdirmax > CIFS_MAX_ACTIMEO) {
1158 if ((ctx->acdirmax != CIFS_DEF_ACTIMEO) ||
1159 (ctx->acregmax != CIFS_DEF_ACTIMEO)) {
1163 ctx->acdirmax = ctx->acregmax = HZ * result.uint_32;
1166 ctx->closetimeo = HZ * result.uint_32;
1167 if (ctx->closetimeo > SMB3_MAX_DCLOSETIMEO) {
1173 ctx->echo_interval = result.uint_32;
1176 ctx->snapshot_time = result.uint_64;
1184 ctx->max_credits = result.uint_32;
1192 ctx->max_channels = result.uint_32;
1195 ctx->multichannel = true;
1203 ctx->max_cached_dirs = result.uint_32;
1206 ctx->handle_timeout = result.uint_32;
1207 if (ctx->handle_timeout > SMB3_MAX_HANDLE_TIMEOUT) {
1213 kfree(ctx->UNC);
1214 ctx->UNC = NULL;
1215 switch (smb3_parse_devname(param->string, ctx)) {
1228 ctx->source = smb3_fs_context_fullpath(ctx, '/');
1229 if (IS_ERR(ctx->source)) {
1230 ctx->source = NULL;
1234 fc->source = kstrdup(ctx->source, GFP_KERNEL);
1241 kfree(ctx->username);
1242 ctx->username = NULL;
1243 if (ctx->nullauth)
1247 ctx->nullauth = 1;
1256 ctx->username = kstrdup(param->string, GFP_KERNEL);
1257 if (ctx->username == NULL) {
1263 kfree_sensitive(ctx->password);
1264 ctx->password = NULL;
1268 ctx->password = kstrdup(param->string, GFP_KERNEL);
1269 if (ctx->password == NULL) {
1276 ctx->got_ip = false;
1279 if (!cifs_convert_address((struct sockaddr *)&ctx->dstaddr,
1285 ctx->got_ip = true;
1294 kfree(ctx->domainname);
1295 ctx->domainname = kstrdup(param->string, GFP_KERNEL);
1296 if (ctx->domainname == NULL) {
1304 (struct sockaddr *)&ctx->srcaddr,
1318 kfree(ctx->iocharset);
1319 ctx->iocharset = kstrdup(param->string, GFP_KERNEL);
1320 if (ctx->iocharset == NULL) {
1328 cifs_dbg(FYI, "iocharset set to %s\n", ctx->iocharset);
1331 memset(ctx->source_rfc1001_name, 0x20,
1342 ctx->source_rfc1001_name[i] = param->string[i];
1352 memset(ctx->target_rfc1001_name, 0x20,
1363 ctx->target_rfc1001_name[i] = param->string[i];
1387 if (cifs_parse_smb_version(fc, param->string, ctx, is_smb3) != 0)
1389 ctx->got_version = true;
1392 if (cifs_parse_security_flavors(fc, param->string, ctx) != 0)
1396 if (cifs_parse_cache_flavor(fc, param->string, ctx) != 0)
1404 ctx->witness = true;
1412 ctx->rootfs = true;
1416 ctx->posix_paths = 0;
1418 ctx->posix_paths = 1;
1422 if (ctx->linux_ext == 1)
1424 ctx->linux_ext = 0;
1425 ctx->no_linux_ext = 1;
1427 if (ctx->no_linux_ext == 1)
1429 ctx->linux_ext = 1;
1430 ctx->no_linux_ext = 0;
1434 ctx->nocase = 1;
1443 if (ctx->file_mode ==
1445 ctx->file_mode = S_IALLUGO;
1446 ctx->nobrl = 1;
1448 ctx->nobrl = 0;
1452 ctx->nohandlecache = 1;
1454 ctx->nohandlecache = 0;
1457 ctx->mand_lock = 1;
1460 ctx->setuids = result.negated;
1463 ctx->intr = !result.negated;
1466 ctx->setuidfromacl = 1;
1469 ctx->nostrictsync = result.negated;
1472 ctx->server_ino = !result.negated;
1475 ctx->rwpidforward = 1;
1478 ctx->mode_ace = 1;
1481 ctx->cifs_acl = !result.negated;
1484 ctx->no_psx_acl = result.negated;
1487 ctx->local_lease = 1;
1490 ctx->sign = true;
1493 ctx->sign = true;
1494 ctx->ignore_signature = true;
1502 ctx->seal = 1;
1512 ctx->fsc = true;
1515 ctx->mfsymlinks = true;
1518 ctx->multiuser = true;
1521 ctx->sloppy = true;
1524 ctx->nosharesock = true;
1528 ctx->nopersistent = true;
1529 if (ctx->persistent) {
1534 ctx->persistent = true;
1535 if ((ctx->nopersistent) || (ctx->resilient)) {
1543 ctx->resilient = false; /* already the default */
1545 ctx->resilient = true;
1546 if (ctx->persistent) {
1555 ctx->sockopt_tcp_nodelay = false;
1557 ctx->sockopt_tcp_nodelay = true;
1560 ctx->domainauto = true;
1563 ctx->rdma = true;
1571 kfree_sensitive(ctx->password);
1572 ctx->password = NULL;
1578 struct smb3_fs_context *ctx;
1582 ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
1583 if (unlikely(!ctx))
1586 strscpy(ctx->workstation_name, nodename, sizeof(ctx->workstation_name));
1593 memset(ctx->source_rfc1001_name, 0x20, RFC1001_NAME_LEN);
1595 ctx->source_rfc1001_name[i] = toupper(nodename[i]);
1597 ctx->source_rfc1001_name[RFC1001_NAME_LEN] = 0;
1602 ctx->target_rfc1001_name[0] = 0;
1603 ctx->cred_uid = current_uid();
1604 ctx->linux_uid = current_uid();
1605 ctx->linux_gid = current_gid();
1607 ctx->bsize = CIFS_DEFAULT_IOSIZE; /* can improve cp performance significantly */
1608 ctx->rasize = 0; /* 0 = use default (ie negotiated rsize) for read ahead pages */
1616 ctx->remap = true;
1619 ctx->dir_mode = ctx->file_mode = S_IRUGO | S_IXUGO | S_IWUSR;
1621 /* ctx->retry default is 0 (i.e. "soft" limited retry not hard retry) */
1623 ctx->posix_paths = 1;
1625 ctx->server_ino = 1;
1628 ctx->strict_io = true;
1630 ctx->acregmax = CIFS_DEF_ACTIMEO;
1631 ctx->acdirmax = CIFS_DEF_ACTIMEO;
1632 ctx->closetimeo = SMB3_DEF_DCLOSETIMEO;
1633 ctx->max_cached_dirs = MAX_CACHED_FIDS;
1635 ctx->handle_timeout = 0; /* See MS-SMB2 spec section 2.2.14.2.12 */
1638 ctx->ops = &smb30_operations;
1639 ctx->vals = &smbdefault_values;
1641 ctx->echo_interval = SMB_ECHO_INTERVAL_DEFAULT;
1644 ctx->multichannel = false;
1645 ctx->max_channels = 1;
1647 ctx->backupuid_specified = false; /* no backup intent for a user */
1648 ctx->backupgid_specified = false; /* no backup intent for a group */
1657 fc->fs_private = ctx;
1663 smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
1665 if (ctx == NULL)
1671 kfree(ctx->username);
1672 ctx->username = NULL;
1673 kfree_sensitive(ctx->password);
1674 ctx->password = NULL;
1675 kfree(ctx->server_hostname);
1676 ctx->server_hostname = NULL;
1677 kfree(ctx->UNC);
1678 ctx->UNC = NULL;
1679 kfree(ctx->source);
1680 ctx->source = NULL;
1681 kfree(ctx->domainname);
1682 ctx->domainname = NULL;
1683 kfree(ctx->nodename);
1684 ctx->nodename = NULL;
1685 kfree(ctx->iocharset);
1686 ctx->iocharset = NULL;
1687 kfree(ctx->prepath);
1688 ctx->prepath = NULL;
1689 kfree(ctx->leaf_fullpath);
1690 ctx->leaf_fullpath = NULL;
1694 smb3_cleanup_fs_context(struct smb3_fs_context *ctx)
1696 if (!ctx)
1698 smb3_cleanup_fs_context_contents(ctx);
1699 kfree(ctx);
1704 struct smb3_fs_context *ctx = cifs_sb->ctx;
1706 if (ctx->nodfs)
1711 if (ctx->noperm)
1716 if (ctx->setuids)
1721 if (ctx->setuidfromacl)
1726 if (ctx->server_ino)
1731 if (ctx->remap)
1736 if (ctx->sfu_remap)
1741 if (ctx->no_xattr)
1746 if (ctx->sfu_emul)
1751 if (ctx->nobrl)
1756 if (ctx->nohandlecache)
1761 if (ctx->nostrictsync)
1766 if (ctx->mand_lock)
1771 if (ctx->rwpidforward)
1776 if (ctx->mode_ace)
1781 if (ctx->cifs_acl)
1786 if (ctx->backupuid_specified)
1791 if (ctx->backupgid_specified)
1796 if (ctx->override_uid)
1801 if (ctx->override_gid)
1806 if (ctx->dynperm)
1811 if (ctx->fsc)
1816 if (ctx->multiuser)
1823 if (ctx->strict_io)
1828 if (ctx->direct_io)
1833 if (ctx->mfsymlinks)
1837 if (ctx->mfsymlinks) {
1838 if (ctx->sfu_emul) {