Skip to content

Commit db0f1c0

Browse files
Paulo Alcantaragregkh
authored andcommitted
smb: client: move most of reparse point handling code to common file
[ Upstream commit c520ba7 ] In preparation to add support for creating special files also via WSL reparse points in next commits. Signed-off-by: Paulo Alcantara <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent c1468c7 commit db0f1c0

File tree

9 files changed

+405
-364
lines changed

9 files changed

+405
-364
lines changed

fs/smb/client/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cifs-y := trace.o cifsfs.o cifs_debug.o connect.o dir.o file.o \
1212
smb2ops.o smb2maperror.o smb2transport.o \
1313
smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o fs_context.o \
1414
dns_resolve.o cifs_spnego_negtokeninit.asn1.o asn1.o \
15-
namespace.o
15+
namespace.o reparse.o
1616

1717
$(obj)/asn1.o: $(obj)/cifs_spnego_negtokeninit.asn1.h
1818

fs/smb/client/cifsglob.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,6 @@ struct cifs_open_info_data {
223223
};
224224
};
225225

226-
static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)
227-
{
228-
struct smb2_file_all_info *fi = &data->fi;
229-
u32 attrs = le32_to_cpu(fi->Attributes);
230-
bool ret;
231-
232-
ret = data->reparse_point || (attrs & ATTR_REPARSE);
233-
if (ret)
234-
attrs |= ATTR_REPARSE;
235-
fi->Attributes = cpu_to_le32(attrs);
236-
return ret;
237-
}
238-
239226
/*
240227
*****************************************************************
241228
* Except the CIFS PDUs themselves all the

fs/smb/client/cifsproto.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@ extern struct inode *cifs_iget(struct super_block *sb,
210210
int cifs_get_inode_info(struct inode **inode, const char *full_path,
211211
struct cifs_open_info_data *data, struct super_block *sb, int xid,
212212
const struct cifs_fid *fid);
213-
bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
214-
struct cifs_fattr *fattr,
215-
struct cifs_open_info_data *data);
216-
217213
extern int smb311_posix_get_inode_info(struct inode **inode,
218214
const char *full_path,
219215
struct cifs_open_info_data *data,

fs/smb/client/inode.c

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "fs_context.h"
2727
#include "cifs_ioctl.h"
2828
#include "cached_dir.h"
29+
#include "reparse.h"
2930

3031
static void cifs_set_ops(struct inode *inode)
3132
{
@@ -728,84 +729,6 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr,
728729
fattr->cf_mode, fattr->cf_uniqueid, fattr->cf_nlink);
729730
}
730731

731-
static inline dev_t nfs_mkdev(struct reparse_posix_data *buf)
732-
{
733-
u64 v = le64_to_cpu(*(__le64 *)buf->DataBuffer);
734-
735-
return MKDEV(v >> 32, v & 0xffffffff);
736-
}
737-
738-
bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
739-
struct cifs_fattr *fattr,
740-
struct cifs_open_info_data *data)
741-
{
742-
struct reparse_posix_data *buf = data->reparse.posix;
743-
u32 tag = data->reparse.tag;
744-
745-
if (tag == IO_REPARSE_TAG_NFS && buf) {
746-
switch (le64_to_cpu(buf->InodeType)) {
747-
case NFS_SPECFILE_CHR:
748-
fattr->cf_mode |= S_IFCHR;
749-
fattr->cf_dtype = DT_CHR;
750-
fattr->cf_rdev = nfs_mkdev(buf);
751-
break;
752-
case NFS_SPECFILE_BLK:
753-
fattr->cf_mode |= S_IFBLK;
754-
fattr->cf_dtype = DT_BLK;
755-
fattr->cf_rdev = nfs_mkdev(buf);
756-
break;
757-
case NFS_SPECFILE_FIFO:
758-
fattr->cf_mode |= S_IFIFO;
759-
fattr->cf_dtype = DT_FIFO;
760-
break;
761-
case NFS_SPECFILE_SOCK:
762-
fattr->cf_mode |= S_IFSOCK;
763-
fattr->cf_dtype = DT_SOCK;
764-
break;
765-
case NFS_SPECFILE_LNK:
766-
fattr->cf_mode |= S_IFLNK;
767-
fattr->cf_dtype = DT_LNK;
768-
break;
769-
default:
770-
WARN_ON_ONCE(1);
771-
return false;
772-
}
773-
return true;
774-
}
775-
776-
switch (tag) {
777-
case IO_REPARSE_TAG_LX_SYMLINK:
778-
fattr->cf_mode |= S_IFLNK;
779-
fattr->cf_dtype = DT_LNK;
780-
break;
781-
case IO_REPARSE_TAG_LX_FIFO:
782-
fattr->cf_mode |= S_IFIFO;
783-
fattr->cf_dtype = DT_FIFO;
784-
break;
785-
case IO_REPARSE_TAG_AF_UNIX:
786-
fattr->cf_mode |= S_IFSOCK;
787-
fattr->cf_dtype = DT_SOCK;
788-
break;
789-
case IO_REPARSE_TAG_LX_CHR:
790-
fattr->cf_mode |= S_IFCHR;
791-
fattr->cf_dtype = DT_CHR;
792-
break;
793-
case IO_REPARSE_TAG_LX_BLK:
794-
fattr->cf_mode |= S_IFBLK;
795-
fattr->cf_dtype = DT_BLK;
796-
break;
797-
case 0: /* SMB1 symlink */
798-
case IO_REPARSE_TAG_SYMLINK:
799-
case IO_REPARSE_TAG_NFS:
800-
fattr->cf_mode |= S_IFLNK;
801-
fattr->cf_dtype = DT_LNK;
802-
break;
803-
default:
804-
return false;
805-
}
806-
return true;
807-
}
808-
809732
static void cifs_open_info_to_fattr(struct cifs_fattr *fattr,
810733
struct cifs_open_info_data *data,
811734
struct super_block *sb)

fs/smb/client/readdir.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "smb2proto.h"
2323
#include "fs_context.h"
2424
#include "cached_dir.h"
25+
#include "reparse.h"
2526

2627
/*
2728
* To be safe - for UCS to UTF-8 with strings loaded with the rare long
@@ -55,23 +56,6 @@ static inline void dump_cifs_file_struct(struct file *file, char *label)
5556
}
5657
#endif /* DEBUG2 */
5758

58-
/*
59-
* Match a reparse point inode if reparse tag and ctime haven't changed.
60-
*
61-
* Windows Server updates ctime of reparse points when their data have changed.
62-
* The server doesn't allow changing reparse tags from existing reparse points,
63-
* though it's worth checking.
64-
*/
65-
static inline bool reparse_inode_match(struct inode *inode,
66-
struct cifs_fattr *fattr)
67-
{
68-
struct timespec64 ctime = inode_get_ctime(inode);
69-
70-
return (CIFS_I(inode)->cifsAttrs & ATTR_REPARSE) &&
71-
CIFS_I(inode)->reparse_tag == fattr->cf_cifstag &&
72-
timespec64_equal(&ctime, &fattr->cf_ctime);
73-
}
74-
7559
/*
7660
* Attempt to preload the dcache with the results from the FIND_FIRST/NEXT
7761
*

0 commit comments

Comments
 (0)