]> Git Repo - linux.git/blame - fs/smb/server/vfs.h
Linux 6.14-rc3
[linux.git] / fs / smb / server / vfs.h
CommitLineData
f4415848
NJ
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2016 Namjae Jeon <[email protected]>
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
5 */
6
7#ifndef __KSMBD_VFS_H__
8#define __KSMBD_VFS_H__
9
10#include <linux/file.h>
11#include <linux/fs.h>
12#include <linux/namei.h>
13#include <uapi/linux/xattr.h>
14#include <linux/posix_acl.h>
dbab80e2 15#include <linux/unicode.h>
f4415848
NJ
16
17#include "smbacl.h"
8b758859 18#include "xattr.h"
f4415848 19
ee2033e9
NJ
20/*
21 * Enumeration for stream type.
22 */
23enum {
24 DATA_STREAM = 1, /* type $DATA */
25 DIR_STREAM /* type $INDEX_ALLOCATION */
26};
27
f4415848 28/* CreateOptions */
f4415848 29#define CREATE_TREE_CONNECTION cpu_to_le32(0x00000080)
f4415848 30#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
f4415848 31
f4415848
NJ
32#define CREATE_OPTION_READONLY 0x10000000
33/* system. NB not sent over wire */
34#define CREATE_OPTION_SPECIAL 0x20000000
35
36struct ksmbd_work;
37struct ksmbd_file;
38struct ksmbd_conn;
39
40struct ksmbd_dir_info {
41 const char *name;
42 char *wptr;
43 char *rptr;
44 int name_len;
45 int out_buf_len;
2b904d61 46 int num_scan;
f4415848
NJ
47 int num_entry;
48 int data_count;
49 int last_entry_offset;
50 bool hide_dot_file;
51 int flags;
04e26094 52 int last_entry_off_align;
f4415848
NJ
53};
54
55struct ksmbd_readdir_data {
56 struct dir_context ctx;
57 union {
58 void *private;
59 char *dirent;
60 };
61
62 unsigned int used;
63 unsigned int dirent_count;
64 unsigned int file_attr;
dbab80e2 65 struct unicode_map *um;
f4415848
NJ
66};
67
68/* ksmbd kstat wrapper to get valid create time when reading dir entry */
69struct ksmbd_kstat {
70 struct kstat *kstat;
71 unsigned long long create_time;
72 __le32 file_attributes;
73};
74
74d7970f 75int ksmbd_vfs_lock_parent(struct dentry *parent, struct dentry *child);
ccb5889a 76void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
af34983e 77 struct dentry *dentry, __le32 *daccess);
f4415848
NJ
78int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode);
79int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode);
e2b76ab8
NJ
80int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
81 loff_t *pos, char *rbuf);
f4415848 82int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
070fb21e
NJ
83 char *buf, size_t count, loff_t *pos, bool sync,
84 ssize_t *written);
64b39f4a 85int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id);
74d7970f 86int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path);
f4415848 87int ksmbd_vfs_link(struct ksmbd_work *work,
070fb21e 88 const char *oldname, const char *newname);
c22180a5 89int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat);
74d7970f
NJ
90int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
91 char *newname, int flags);
265fd199 92int ksmbd_vfs_truncate(struct ksmbd_work *work,
070fb21e 93 struct ksmbd_file *fp, loff_t size);
f4415848
NJ
94struct srv_copychunk;
95int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
070fb21e
NJ
96 struct ksmbd_file *src_fp,
97 struct ksmbd_file *dst_fp,
98 struct srv_copychunk *chunks,
99 unsigned int chunk_count,
100 unsigned int *chunk_count_written,
101 unsigned int *chunk_size_written,
102 loff_t *total_size_written);
f4415848 103ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);
4609e1f1 104ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
af34983e
HL
105 struct dentry *dentry,
106 char *xattr_name,
070fb21e 107 char **xattr_buf);
4609e1f1 108ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
af34983e 109 struct dentry *dentry, char *attr_name,
070fb21e 110 int attr_name_len);
4609e1f1 111int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
40b268d3 112 const struct path *path, const char *attr_name,
864fb5d3
NJ
113 void *attr_value, size_t attr_size, int flags,
114 bool get_write);
64b39f4a 115int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
070fb21e 116 size_t *xattr_stream_name_size, int s_type);
4609e1f1 117int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
2bfc4214
NJ
118 const struct path *path, char *attr_name,
119 bool get_write);
74d7970f 120int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
2b57a432
NJ
121 unsigned int flags, struct path *parent_path,
122 struct path *path, bool caseless);
864fb5d3 123void ksmbd_vfs_kern_path_unlock(struct path *parent_path, struct path *path);
265fd199
HL
124struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
125 const char *name,
126 unsigned int flags,
127 struct path *path);
f4415848
NJ
128int ksmbd_vfs_empty_dir(struct ksmbd_file *fp);
129void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option);
64b39f4a 130int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,
070fb21e 131 loff_t off, loff_t len);
f4415848
NJ
132struct file_allocated_range_buffer;
133int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
070fb21e 134 struct file_allocated_range_buffer *ranges,
f7db8fd0 135 unsigned int in_count, unsigned int *out_count);
74d7970f 136int ksmbd_vfs_unlink(struct file *filp);
f4415848 137void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);
af34983e 138int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
b74d24f7 139 struct mnt_idmap *idmap,
af34983e 140 struct dentry *dentry,
070fb21e 141 struct ksmbd_kstat *ksmbd_kstat);
45a64e8b 142void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
f4415848 143void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
13e83a49 144int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
40b268d3
NJ
145 const struct path *path);
146int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path);
af34983e 147int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
4609e1f1 148 struct mnt_idmap *idmap,
40b268d3 149 const struct path *path,
864fb5d3
NJ
150 struct smb_ntsd *pntsd, int len,
151 bool get_write);
af34983e 152int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
4609e1f1 153 struct mnt_idmap *idmap,
af34983e 154 struct dentry *dentry,
070fb21e 155 struct smb_ntsd **pntsd);
4609e1f1 156int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
40b268d3 157 const struct path *path,
864fb5d3
NJ
158 struct xattr_dos_attrib *da,
159 bool get_write);
4609e1f1 160int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
af34983e 161 struct dentry *dentry,
070fb21e 162 struct xattr_dos_attrib *da);
13e83a49 163int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
40b268d3 164 struct path *path);
13e83a49 165int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
40b268d3 166 struct path *path,
070fb21e 167 struct inode *parent_inode);
f4415848 168#endif /* __KSMBD_VFS_H__ */
This page took 0.304733 seconds and 4 git commands to generate.