linux/fs/smb/server/smb_common.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
 */

#ifndef __SMB_COMMON_H__
#define __SMB_COMMON_H__

#include <linux/kernel.h>

#include "glob.h"
#include "nterr.h"
#include "../common/smb2pdu.h"
#include "smb2pdu.h"

/* ksmbd's Specific ERRNO */
#define ESHARE

#define SMB1_PROT
#define SMB2_PROT
#define SMB21_PROT
/* multi-protocol negotiate request */
#define SMB2X_PROT
#define SMB30_PROT
#define SMB302_PROT
#define SMB311_PROT
#define BAD_PROT

#define SMB1_VERSION_STRING
#define SMB20_VERSION_STRING
#define SMB21_VERSION_STRING
#define SMB30_VERSION_STRING
#define SMB302_VERSION_STRING
#define SMB311_VERSION_STRING

#define SMB_ECHO_INTERVAL

#define CIFS_DEFAULT_IOSIZE
#define MAX_CIFS_SMALL_BUFFER_SIZE

#define MAX_STREAM_PROT_LEN

/* Responses when opening a file. */
#define F_SUPERSEDED
#define F_OPENED
#define F_CREATED
#define F_OVERWRITTEN

/*
 * File Attribute flags
 */
#define ATTR_POSIX_SEMANTICS
#define ATTR_BACKUP_SEMANTICS
#define ATTR_DELETE_ON_CLOSE
#define ATTR_SEQUENTIAL_SCAN
#define ATTR_RANDOM_ACCESS
#define ATTR_NO_BUFFERING
#define ATTR_WRITE_THROUGH

/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
#define FILE_SUPPORTS_SPARSE_VDL
#define FILE_SUPPORTS_BLOCK_REFCOUNTING
#define FILE_SUPPORT_INTEGRITY_STREAMS
#define FILE_SUPPORTS_USN_JOURNAL
#define FILE_SUPPORTS_OPEN_BY_FILE_ID
#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES
#define FILE_SUPPORTS_HARD_LINKS
#define FILE_SUPPORTS_TRANSACTIONS
#define FILE_SEQUENTIAL_WRITE_ONCE
#define FILE_READ_ONLY_VOLUME
#define FILE_NAMED_STREAMS
#define FILE_SUPPORTS_ENCRYPTION
#define FILE_SUPPORTS_OBJECT_IDS
#define FILE_VOLUME_IS_COMPRESSED
#define FILE_SUPPORTS_REMOTE_STORAGE
#define FILE_SUPPORTS_REPARSE_POINTS
#define FILE_SUPPORTS_SPARSE_FILES
#define FILE_VOLUME_QUOTAS
#define FILE_FILE_COMPRESSION
#define FILE_PERSISTENT_ACLS
#define FILE_UNICODE_ON_DISK
#define FILE_CASE_PRESERVED_NAMES
#define FILE_CASE_SENSITIVE_SEARCH

#define FILE_READ_DATA
#define FILE_WRITE_DATA
#define FILE_APPEND_DATA
#define FILE_READ_EA
/* with the file can be read        */
#define FILE_WRITE_EA
/* with the file can be written     */
#define FILE_EXECUTE
/* the file using system paging I/O */
#define FILE_DELETE_CHILD
#define FILE_READ_ATTRIBUTES
/* file can be read                 */
#define FILE_WRITE_ATTRIBUTES
/* file can be written              */
#define DELETE
#define READ_CONTROL
/* ownership associated with the    */
/* file can be read                 */
#define WRITE_DAC
/* ownership associated with the    */
/* file can be written.             */
#define WRITE_OWNER
/* with the file can be written     */
#define SYNCHRONIZE
/* synchronize with the completion  */
/* of an input/output request       */
#define GENERIC_ALL
#define GENERIC_EXECUTE
#define GENERIC_WRITE
#define GENERIC_READ
/* In summary - Relevant file       */
/* access flags from CIFS are       */
/* file_read_data, file_write_data  */
/* file_execute, file_read_attributes*/
/* write_dac, and delete.           */

#define SET_FILE_READ_RIGHTS
#define SET_FILE_WRITE_RIGHTS
#define SET_FILE_EXEC_RIGHTS

#define SET_MINIMUM_RIGHTS

/* generic flags for file open */
#define GENERIC_READ_FLAGS

#define GENERIC_WRITE_FLAGS

#define GENERIC_EXECUTE_FLAGS

#define GENERIC_ALL_FLAGS

#define SMB1_PROTO_NUMBER
#define SMB_COM_NEGOTIATE
#define SMB1_CLIENT_GUID_SIZE

#define SMBFLG_RESPONSE

#define SMBFLG2_IS_LONG_NAME
#define SMBFLG2_EXT_SEC
#define SMBFLG2_ERR_STATUS
#define SMBFLG2_UNICODE

struct smb_hdr {} __packed;

struct smb_negotiate_req {} __packed;

struct smb_negotiate_rsp {} __packed;

struct filesystem_attribute_info {} __packed;

struct filesystem_device_info {} __packed; /* device info level 0x104 */

struct filesystem_vol_info {} __packed;

struct filesystem_info {} __packed;     /* size info, level 0x103 */

#define EXTENDED_INFO_MAGIC
#define STRING_LENGTH

struct fs_extended_info {} __packed;

struct object_id_info {} __packed;

struct file_directory_info {} __packed;   /* level 0x101 FF resp data */

struct file_names_info {} __packed;   /* level 0xc FF resp data */

struct file_full_directory_info {} __packed; /* level 0x102 FF resp */

struct file_both_directory_info {} __packed; /* level 0x104 FFrsp data */

struct file_id_both_directory_info {} __packed;

struct file_id_full_dir_info {} __packed; /* level 0x105 FF rsp data */

struct smb_version_values {};

struct filesystem_posix_info {} __packed;

struct smb_version_ops {};

struct smb_version_cmds {};

int ksmbd_min_protocol(void);
int ksmbd_max_protocol(void);

int ksmbd_lookup_protocol_idx(char *str);

int ksmbd_verify_smb_message(struct ksmbd_work *work);
bool ksmbd_smb_request(struct ksmbd_conn *conn);

int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count);

int ksmbd_init_smb_server(struct ksmbd_work *work);

struct ksmbd_kstat;
int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work,
				      int info_level,
				      struct ksmbd_file *dir,
				      struct ksmbd_dir_info *d_info,
				      char *search_pattern,
				      int (*fn)(struct ksmbd_conn *,
						int,
						struct ksmbd_dir_info *,
						struct ksmbd_kstat *));

int ksmbd_extract_shortname(struct ksmbd_conn *conn,
			    const char *longname,
			    char *shortname);

int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command);

int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp);
int ksmbd_override_fsids(struct ksmbd_work *work);
void ksmbd_revert_fsids(struct ksmbd_work *work);

unsigned int ksmbd_server_side_copy_max_chunk_count(void);
unsigned int ksmbd_server_side_copy_max_chunk_size(void);
unsigned int ksmbd_server_side_copy_max_total_size(void);
bool is_asterisk(char *p);
__le32 smb_map_generic_desired_access(__le32 daccess);

static inline unsigned int get_rfc1002_len(void *buf)
{}

static inline void inc_rfc1001_len(void *buf, int count)
{}
#endif /* __SMB_COMMON_H__ */