xref: /linux/fs/smb/server/misc.h (revision 995832b2cebe6969d1b42635db698803ee31294d)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
4  */
5 
6 #ifndef __KSMBD_MISC_H__
7 #define __KSMBD_MISC_H__
8 
9 #ifdef CONFIG_PROC_FS
10 #include <linux/proc_fs.h>
11 #endif
12 struct ksmbd_share_config;
13 struct nls_table;
14 struct kstat;
15 struct ksmbd_file;
16 
17 int match_pattern(const char *str, size_t len, const char *pattern);
18 int ksmbd_validate_filename(char *filename);
19 int parse_stream_name(char *filename, char **stream_name, int *s_type);
20 char *convert_to_nt_pathname(struct ksmbd_share_config *share,
21 			     const struct path *path);
22 int get_nlink(struct kstat *st);
23 void ksmbd_conv_path_to_unix(char *path);
24 void ksmbd_strip_last_slash(char *path);
25 void ksmbd_conv_path_to_windows(char *path);
26 char *ksmbd_casefold_sharename(struct unicode_map *um, const char *name);
27 char *ksmbd_extract_sharename(struct unicode_map *um, const char *treename);
28 
29 #define KSMBD_DIR_INFO_ALIGNMENT	8
30 struct ksmbd_dir_info;
31 char *ksmbd_convert_dir_info_name(struct ksmbd_dir_info *d_info,
32 				  const struct nls_table *local_nls,
33 				  int *conv_len);
34 
35 #define NTFS_TIME_OFFSET	((u64)(369 * 365 + 89) * 24 * 3600 * 10000000)
36 struct timespec64 ksmbd_NTtimeToUnix(__le64 ntutc);
37 u64 ksmbd_UnixTimeToNT(struct timespec64 t);
38 long long ksmbd_systime(void);
39 
40 #ifdef CONFIG_PROC_FS
41 struct ksmbd_const_name {
42 	unsigned int const_value;
43 	const char *name;
44 };
45 
46 void ksmbd_proc_init(void);
47 void ksmbd_proc_cleanup(void);
48 void ksmbd_proc_reset(void);
49 struct proc_dir_entry *ksmbd_proc_create(const char *name,
50 					 int (*show)(struct seq_file *m, void *v),
51 			     void *v);
52 void ksmbd_proc_show_flag_names(struct seq_file *m,
53 				const struct ksmbd_const_name *table,
54 				int count,
55 				unsigned int flags);
56 void ksmbd_proc_show_const_name(struct seq_file *m,
57 				const char *format,
58 				const struct ksmbd_const_name *table,
59 				int count,
60 				unsigned int const_value);
61 #else
62 static inline void ksmbd_proc_init(void) {}
63 static inline void ksmbd_proc_cleanup(void) {}
64 static inline void ksmbd_proc_reset(void) {}
65 #endif
66 #endif /* __KSMBD_MISC_H__ */
67