• Home
  • Raw
  • Download

Lines Matching +full:tcon +full:- +full:top

1 // SPDX-License-Identifier: GPL-2.0-only
24 struct dentry *dentry, struct cifs_tcon *tcon, in smb2_create_reparse_symlink() argument
29 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in smb2_create_reparse_symlink()
39 return -ENAMETOOLONG; in smb2_create_reparse_symlink()
43 return -ENOMEM; in smb2_create_reparse_symlink()
54 rc = -ENOMEM; in smb2_create_reparse_symlink()
61 * directory cannot be resolved and vice-versa). Try to detect if in smb2_create_reparse_symlink()
63 * fails then treat symlink as a file (non-directory) symlink. in smb2_create_reparse_symlink()
74 rc = -ENOMEM; in smb2_create_reparse_symlink()
78 buf->ReparseTag = cpu_to_le32(IO_REPARSE_TAG_SYMLINK); in smb2_create_reparse_symlink()
79 buf->ReparseDataLength = cpu_to_le16(len - sizeof(struct reparse_data_buffer)); in smb2_create_reparse_symlink()
80 buf->SubstituteNameOffset = cpu_to_le16(plen); in smb2_create_reparse_symlink()
81 buf->SubstituteNameLength = cpu_to_le16(plen); in smb2_create_reparse_symlink()
82 memcpy(&buf->PathBuffer[plen], path, plen); in smb2_create_reparse_symlink()
83 buf->PrintNameOffset = 0; in smb2_create_reparse_symlink()
84 buf->PrintNameLength = cpu_to_le16(plen); in smb2_create_reparse_symlink()
85 memcpy(buf->PathBuffer, path, plen); in smb2_create_reparse_symlink()
86 buf->Flags = cpu_to_le32(*symname != '/' ? SYMLINK_FLAG_RELATIVE : 0); in smb2_create_reparse_symlink()
88 buf->Flags = cpu_to_le32(SYMLINK_FLAG_RELATIVE); in smb2_create_reparse_symlink()
93 new = smb2_get_reparse_inode(&data, inode->i_sb, xid, in smb2_create_reparse_symlink()
94 tcon, full_path, directory, in smb2_create_reparse_symlink()
116 struct cifs_tcon *tcon; in detect_directory_symlink_target() local
129 * with slash, or last path component is dot or dot-dot then it is for in detect_directory_symlink_target()
169 return -ENOMEM; in detect_directory_symlink_target()
186 tcon = tlink_tcon(tlink); in detect_directory_symlink_target()
187 oparms = CIFS_OPARMS(cifs_sb, tcon, resolved_path, in detect_directory_symlink_target()
195 open_rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, NULL); in detect_directory_symlink_target()
199 tcon->ses->server->ops->close(xid, tcon, &fid); in detect_directory_symlink_target()
200 } else if (open_rc == -ENOTDIR) { in detect_directory_symlink_target()
201 /* -ENOTDIR means that the target path is definitely a file. */ in detect_directory_symlink_target()
203 } else if (open_rc == -ENOENT) { in detect_directory_symlink_target()
204 /* -ENOENT means that the target path does not exist. */ in detect_directory_symlink_target()
214 open_rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, NULL); in detect_directory_symlink_target()
218 tcon->ses->server->ops->close(xid, tcon, &fid); in detect_directory_symlink_target()
219 } else if (open_rc == -EISDIR) { in detect_directory_symlink_target()
220 /* -EISDIR means that the target path is definitely a directory. */ in detect_directory_symlink_target()
228 * TODO: Try to use ops->query_dir_first on the parent directory in detect_directory_symlink_target()
264 return -EOPNOTSUPP; in nfs_set_reparse_buf()
267 buf->ReparseTag = cpu_to_le32(IO_REPARSE_TAG_NFS); in nfs_set_reparse_buf()
268 buf->Reserved = 0; in nfs_set_reparse_buf()
269 buf->InodeType = cpu_to_le64(type); in nfs_set_reparse_buf()
270 buf->ReparseDataLength = cpu_to_le16(len + dlen - in nfs_set_reparse_buf()
272 *(__le64 *)buf->DataBuffer = cpu_to_le64(((u64)MINOR(dev) << 32) | in nfs_set_reparse_buf()
274 iov->iov_base = buf; in nfs_set_reparse_buf()
275 iov->iov_len = len + dlen; in nfs_set_reparse_buf()
280 struct dentry *dentry, struct cifs_tcon *tcon, in mknod_nfs() argument
300 new = smb2_get_reparse_inode(&data, inode->i_sb, xid, in mknod_nfs()
301 tcon, full_path, false, &iov, NULL); in mknod_nfs()
322 return -EOPNOTSUPP; in wsl_set_reparse_buf()
325 buf->ReparseTag = cpu_to_le32(tag); in wsl_set_reparse_buf()
326 buf->Reserved = 0; in wsl_set_reparse_buf()
327 buf->ReparseDataLength = 0; in wsl_set_reparse_buf()
328 iov->iov_base = buf; in wsl_set_reparse_buf()
329 iov->iov_len = sizeof(*buf); in wsl_set_reparse_buf()
340 return ERR_PTR(-ENOMEM); in ea_create_context()
342 cc->ctx.NameOffset = cpu_to_le16(offsetof(struct smb2_create_ea_ctx, in ea_create_context()
344 cc->ctx.NameLength = cpu_to_le16(4); in ea_create_context()
345 memcpy(cc->name, SMB2_CREATE_EA_BUFFER, strlen(SMB2_CREATE_EA_BUFFER)); in ea_create_context()
346 cc->ctx.DataOffset = cpu_to_le16(offsetof(struct smb2_create_ea_ctx, ea)); in ea_create_context()
347 cc->ctx.DataLength = cpu_to_le32(dlen); in ea_create_context()
363 struct smb3_fs_context *ctx = CIFS_SB(inode->i_sb)->ctx; in wsl_set_xattrs()
364 __le64 uid = cpu_to_le64(from_kuid(current_user_ns(), ctx->linux_uid)); in wsl_set_xattrs()
365 __le64 gid = cpu_to_le64(from_kgid(current_user_ns(), ctx->linux_gid)); in wsl_set_xattrs()
383 num_xattrs = ARRAY_SIZE(xattrs) - 1; in wsl_set_xattrs()
397 ea = &cc->ea; in wsl_set_xattrs()
401 ea->next_entry_offset = cpu_to_le32(next); in wsl_set_xattrs()
403 ea->ea_name_length = name_size - 1; in wsl_set_xattrs()
404 ea->ea_value_length = cpu_to_le16(xattrs[i].size); in wsl_set_xattrs()
405 memcpy(ea->ea_data, xattrs[i].name, name_size); in wsl_set_xattrs()
406 memcpy(&ea->ea_data[name_size], in wsl_set_xattrs()
409 ea->next_entry_offset = 0; in wsl_set_xattrs()
411 iov->iov_base = cc; in wsl_set_xattrs()
412 iov->iov_len = cc_len; in wsl_set_xattrs()
417 struct dentry *dentry, struct cifs_tcon *tcon, in mknod_wsl() argument
442 len = le32_to_cpu(cc->ctx.DataLength); in mknod_wsl()
443 memcpy(data.wsl.eas, &cc->ea, len); in mknod_wsl()
446 new = smb2_get_reparse_inode(&data, inode->i_sb, in mknod_wsl()
447 xid, tcon, full_path, false, in mknod_wsl()
459 struct dentry *dentry, struct cifs_tcon *tcon, in smb2_mknod_reparse() argument
462 struct smb3_fs_context *ctx = CIFS_SB(inode->i_sb)->ctx; in smb2_mknod_reparse()
463 int rc = -EOPNOTSUPP; in smb2_mknod_reparse()
465 switch (ctx->reparse_type) { in smb2_mknod_reparse()
467 rc = mknod_nfs(xid, inode, dentry, tcon, full_path, mode, dev); in smb2_mknod_reparse()
470 rc = mknod_wsl(xid, inode, dentry, tcon, full_path, mode, dev); in smb2_mknod_reparse()
476 /* See MS-FSCC 2.1.2.6 for the 'NFS' style reparse tags */
484 len = le16_to_cpu(buf->ReparseDataLength); in parse_reparse_posix()
485 if (len < sizeof(buf->InodeType)) { in parse_reparse_posix()
487 return -EIO; in parse_reparse_posix()
490 len -= sizeof(buf->InodeType); in parse_reparse_posix()
492 switch ((type = le64_to_cpu(buf->InodeType))) { in parse_reparse_posix()
496 return -EIO; in parse_reparse_posix()
499 * Check that buffer does not contain UTF-16 null codepoint in parse_reparse_posix()
502 if (UniStrnlen((wchar_t *)buf->DataBuffer, len/2) != len/2) { in parse_reparse_posix()
504 return -EIO; in parse_reparse_posix()
506 data->symlink_target = cifs_strndup_from_utf16(buf->DataBuffer, in parse_reparse_posix()
508 cifs_sb->local_nls); in parse_reparse_posix()
509 if (!data->symlink_target) in parse_reparse_posix()
510 return -ENOMEM; in parse_reparse_posix()
512 __func__, data->symlink_target); in parse_reparse_posix()
516 /* DataBuffer for block and char devices contains two 32-bit numbers */ in parse_reparse_posix()
519 return -EIO; in parse_reparse_posix()
527 return -EIO; in parse_reparse_posix()
533 return -EOPNOTSUPP; in parse_reparse_posix()
550 smb_target = cifs_strndup_from_utf16(buf, len, unicode, cifs_sb->local_nls); in smb2_parse_native_symlink()
552 rc = -ENOMEM; in smb2_parse_native_symlink()
558 * This is a relative SMB symlink from the top of the share, in smb2_parse_native_symlink()
559 * which is the top level directory of the Linux mount point. in smb2_parse_native_symlink()
575 rc = -ENOMEM; in smb2_parse_native_symlink()
613 /* We handle Symbolic Link reparse tag here. See: MS-FSCC 2.1.2.4 */ in parse_reparse_symlink()
615 offs = le16_to_cpu(sym->SubstituteNameOffset); in parse_reparse_symlink()
616 len = le16_to_cpu(sym->SubstituteNameLength); in parse_reparse_symlink()
619 return -EIO; in parse_reparse_symlink()
622 return smb2_parse_native_symlink(&data->symlink_target, in parse_reparse_symlink()
623 sym->PathBuffer + offs, in parse_reparse_symlink()
626 le32_to_cpu(sym->Flags) & SYMLINK_FLAG_RELATIVE, in parse_reparse_symlink()
636 data->reparse.buf = buf; in parse_reparse_point()
638 /* See MS-FSCC 2.1.2 */ in parse_reparse_point()
639 switch (le32_to_cpu(buf->ReparseTag)) { in parse_reparse_point()
652 if (le16_to_cpu(buf->ReparseDataLength) != 0) { in parse_reparse_point()
654 le32_to_cpu(buf->ReparseTag)); in parse_reparse_point()
655 return -EIO; in parse_reparse_point()
659 return -EOPNOTSUPP; in parse_reparse_point()
669 struct smb2_ioctl_rsp *io = rsp_iov->iov_base; in smb2_parse_reparse_point()
670 u32 plen = le32_to_cpu(io->OutputCount); in smb2_parse_reparse_point()
673 le32_to_cpu(io->OutputOffset)); in smb2_parse_reparse_point()
687 fattr->cf_mode |= S_IFLNK; in wsl_to_fattr()
690 fattr->cf_mode |= S_IFIFO; in wsl_to_fattr()
693 fattr->cf_mode |= S_IFSOCK; in wsl_to_fattr()
696 fattr->cf_mode |= S_IFCHR; in wsl_to_fattr()
699 fattr->cf_mode |= S_IFBLK; in wsl_to_fattr()
703 if (!data->wsl.eas_len) in wsl_to_fattr()
706 ea = (struct smb2_file_full_ea_info *)data->wsl.eas; in wsl_to_fattr()
713 next = le32_to_cpu(ea->next_entry_offset); in wsl_to_fattr()
714 if (!le16_to_cpu(ea->ea_value_length)) in wsl_to_fattr()
717 name = ea->ea_data; in wsl_to_fattr()
718 nlen = ea->ea_name_length; in wsl_to_fattr()
719 v = (void *)((u8 *)ea->ea_data + ea->ea_name_length + 1); in wsl_to_fattr()
722 fattr->cf_uid = wsl_make_kuid(cifs_sb, v); in wsl_to_fattr()
724 fattr->cf_gid = wsl_make_kgid(cifs_sb, v); in wsl_to_fattr()
727 if (S_DT(fattr->cf_mode) != S_DT(le32_to_cpu(*(__le32 *)v))) in wsl_to_fattr()
729 fattr->cf_mode = (umode_t)le32_to_cpu(*(__le32 *)v); in wsl_to_fattr()
731 fattr->cf_rdev = reparse_mkdev(v); in wsl_to_fattr()
748 struct reparse_posix_data *buf = data->reparse.posix; in posix_reparse_to_fattr()
754 if (le16_to_cpu(buf->ReparseDataLength) < sizeof(buf->InodeType)) { in posix_reparse_to_fattr()
759 switch (le64_to_cpu(buf->InodeType)) { in posix_reparse_to_fattr()
761 if (le16_to_cpu(buf->ReparseDataLength) != sizeof(buf->InodeType) + 8) { in posix_reparse_to_fattr()
765 fattr->cf_mode |= S_IFCHR; in posix_reparse_to_fattr()
766 fattr->cf_rdev = reparse_mkdev(buf->DataBuffer); in posix_reparse_to_fattr()
769 if (le16_to_cpu(buf->ReparseDataLength) != sizeof(buf->InodeType) + 8) { in posix_reparse_to_fattr()
773 fattr->cf_mode |= S_IFBLK; in posix_reparse_to_fattr()
774 fattr->cf_rdev = reparse_mkdev(buf->DataBuffer); in posix_reparse_to_fattr()
777 fattr->cf_mode |= S_IFIFO; in posix_reparse_to_fattr()
780 fattr->cf_mode |= S_IFSOCK; in posix_reparse_to_fattr()
783 fattr->cf_mode |= S_IFLNK; in posix_reparse_to_fattr()
796 u32 tag = data->reparse.tag; in cifs_reparse_point_to_fattr()
801 if (!(fattr->cf_cifsattrs & ATTR_DIRECTORY)) in cifs_reparse_point_to_fattr()
808 fattr->cf_mode = S_IFDIR | 0711; in cifs_reparse_point_to_fattr()
826 fattr->cf_mode |= S_IFLNK; in cifs_reparse_point_to_fattr()
832 fattr->cf_dtype = S_DT(fattr->cf_mode); in cifs_reparse_point_to_fattr()