?? smb.h
字號:
//
// smb.h
//
// SMB filesystem definitions
//
// Copyright (C) 2002 Michael Ringgaard. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
#ifndef SMB_H
#define SMB_H
#define ROUNDUP(x) (((x) + 3) & ~3)
#define SMB_NAMELEN 256
#define SMB_DENTRY_CACHESIZE 16
#define SMB_DIRBUF_SIZE 4096
#define SMB_RAW_CHUNKSIZE (32 * K)
#define SMB_NORMAL_CHUNKSIZE (4 * K)
#define EPOC 116444736000000000 // 00:00:00 GMT on January 1, 1970
#define SECTIMESCALE 10000000 // 1 sec resolution
#define SMB_HEADER_LEN 35
#define SMB_MAX_BUFFER 4356
#define SMB_BLK_SIZE 4096
#define SMB_CLIENT_OS "sanos"
#define SMB_CLIENT_LANMAN "smbfs"
#define SMB_SERVICE_DISK "A:"
//
// SMB Command Codes
//
#define SMB_COM_CREATE_DIRECTORY 0x00
#define SMB_COM_DELETE_DIRECTORY 0x01
#define SMB_COM_OPEN 0x02
#define SMB_COM_CREATE 0x03
#define SMB_COM_CLOSE 0x04
#define SMB_COM_FLUSH 0x05
#define SMB_COM_DELETE 0x06
#define SMB_COM_RENAME 0x07
#define SMB_COM_QUERY_INFORMATION 0x08
#define SMB_COM_SET_INFORMATION 0x09
#define SMB_COM_READ 0x0A
#define SMB_COM_WRITE 0x0B
#define SMB_COM_LOCK_BYTE_RANGE 0x0C
#define SMB_COM_UNLOCK_BYTE_RANGE 0x0D
#define SMB_COM_CREATE_TEMPORARY 0x0E
#define SMB_COM_CREATE_NEW 0x0F
#define SMB_COM_CHECK_DIRECTORY 0x10
#define SMB_COM_PROCESS_EXIT 0x11
#define SMB_COM_SEEK 0x12
#define SMB_COM_LOCK_AND_READ 0x13
#define SMB_COM_WRITE_AND_UNLOCK 0x14
#define SMB_COM_READ_RAW 0x1A
#define SMB_COM_READ_MPX 0x1B
#define SMB_COM_READ_MPX_SECONDARY 0x1C
#define SMB_COM_WRITE_RAW 0x1D
#define SMB_COM_WRITE_MPX 0x1E
#define SMB_COM_WRITE_COMPLETE 0x20
#define SMB_COM_SET_INFORMATION2 0x22
#define SMB_COM_QUERY_INFORMATION2 0x23
#define SMB_COM_LOCKING_ANDX 0x24
#define SMB_COM_TRANSACTION 0x25
#define SMB_COM_TRANSACTION_SECONDARY 0x26
#define SMB_COM_IOCTL 0x27
#define SMB_COM_IOCTL_SECONDARY 0x28
#define SMB_COM_COPY 0x29
#define SMB_COM_MOVE 0x2A
#define SMB_COM_ECHO 0x2B
#define SMB_COM_WRITE_AND_CLOSE 0x2C
#define SMB_COM_OPEN_ANDX 0x2D
#define SMB_COM_READ_ANDX 0x2E
#define SMB_COM_WRITE_ANDX 0x2F
#define SMB_COM_CLOSE_AND_TREE_DISC 0x31
#define SMB_COM_TRANSACTION2 0x32
#define SMB_COM_TRANSACTION2_SECONDARY 0x33
#define SMB_COM_FIND_CLOSE2 0x34
#define SMB_COM_FIND_NOTIFY_CLOSE 0x35
#define SMB_COM_TREE_CONNECT 0x70
#define SMB_COM_TREE_DISCONNECT 0x71
#define SMB_COM_NEGOTIATE 0x72
#define SMB_COM_SESSION_SETUP_ANDX 0x73
#define SMB_COM_LOGOFF_ANDX 0x74
#define SMB_COM_TREE_CONNECT_ANDX 0x75
#define SMB_COM_QUERY_INFORMATION_DISK 0x80
#define SMB_COM_SEARCH 0x81
#define SMB_COM_FIND 0x82
#define SMB_COM_FIND_UNIQUE 0x83
#define SMB_COM_NT_TRANSACT 0xA0
#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
#define SMB_COM_NT_CREATE_ANDX 0xA2
#define SMB_COM_NT_CANCEL 0xA4
#define SMB_COM_OPEN_PRINT_FILE 0xC0
#define SMB_COM_WRITE_PRINT_FILE 0xC1
#define SMB_COM_CLOSE_PRINT_FILE 0xC2
#define SMB_COM_GET_PRINT_QUEUE 0xC3
#define SMB_COM_READ_BULK 0xD8
#define SMB_COM_WRITE_BULK 0xD9
#define SMB_COM_WRITE_BULK_DATA 0xDA
//
// SMB TRANS2 sub commands
#define TRANS2_OPEN2 0x00 // Create file with extended attributes
#define TRANS2_FIND_FIRST2 0x01 // Begin search for files
#define TRANS2_FIND_NEXT2 0x02 // Resume search for files
#define TRANS2_QUERY_FS_INFORMATION 0x03 // Get file system information
#define TRANS2_QUERY_PATH_INFORMATION 0x05 // Get information about a named file or directory
#define TRANS2_SET_PATH_INFORMATION 0x06 // Set information about a named file or directory
#define TRANS2_QUERY_FILE_INFORMATION 0x07 // Get information about a handle
#define TRANS2_SET_FILE_INFORMATION 0x08 // Set information by handle
#define TRANS2_FSCTL 0x09 // Not implemented by NT server
#define TRANS2_IOCTL2 0x0A // Not implemented by NT server
#define TRANS2_FIND_NOTIFY_FIRST 0x0B // Not implemented by NT server
#define TRANS2_FIND_NOTIFY_NEXT 0x0C // Not implemented by NT server
#define TRANS2_CREATE_DIRECTORY 0x0D // Create directory with extended attributes
#define TRANS2_SESSION_SETUP 0x0E // Session setup with extended security information
#define TRANS2_GET_DFS_REFERRAL 0x10 // Get a DFS referral
#define TRANS2_REPORT_DFS_INCONSISTENCY 0x11 // Report a DFS knowledge inconsistency
//
// SMB protocol capability flags
//
#define SMB_CAP_RAW_MODE 0x0001
#define SMB_CAP_MPX_MODE 0x0002
#define SMB_CAP_UNICODE 0x0004
#define SMB_CAP_LARGE_FILES 0x0008
#define SMB_CAP_NT_SMBS 0x0010
#define SMB_CAP_RPC_REMOTE_APIS 0x0020
#define SMB_CAP_STATUS32 0x0040
#define SMB_CAP_LEVEL_II_OPLOCKS 0x0080
#define SMB_CAP_LOCK_AND_READ 0x0100
#define SMB_CAP_NT_FIND 0x0200
#define SMB_CAP_DFS 0x1000
#define SMB_CAP_LARGE_READX 0x4000
//
// SMB file attributes and flags
//
#define SMB_FILE_ATTR_ARCHIVE 0x020 // The file has not been archived since it was last modified.
#define SMB_FILE_ATTR_COMPRESSED 0x800 // The file or directory is compressed.
#define SMB_FILE_ATTR_NORMAL 0x080 // The file has no other attributes set.
#define SMB_FILE_ATTR_HIDDEN 0x002 // The file is hidden.
#define SMB_FILE_ATTR_READONLY 0x001 // The file is read only.
#define SMB_FILE_ATTR_TEMPORARY 0x100 // The file is temporary
#define SMB_FILE_ATTR_DIRECTORY 0x010 // The file is a directory
#define SMB_FILE_ATTR_SYSTEM 0x004 // The file is part of or is used exclusively by the operating system.
#define SMB_FILE_FLAG_WRITE_THROUGH 0x80000000
#define SMB_FILE_FLAG_NO_BUFFERING 0x20000000
#define SMB_FILE_FLAG_RANDOM_ACCESS 0x10000000
#define SMB_FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
#define SMB_FILE_FLAG_DELETE_ON_CLOSE 0x04000000
#define SMB_FILE_FLAG_BACKUP_SEMANTICS 0x02000000
#define SMB_FILE_FLAG_POSIX_SEMANTICS 0x01000000
//
// SMB access mask
#define SMB_ACCESS_DELETE 0x00010000
#define SMB_ACCESS_READ_CONTROL 0x00020000
#define SMB_ACCESS_WRITE_DAC 0x00040000
#define SMB_ACCESS_WRITE_OWNER 0x00080000
#define SMB_ACCESS_SYNCHRONIZE 0x00100000
#define SMB_ACCESS_GENERIC_READ 0x80000000
#define SMB_ACCESS_GENERIC_WRITE 0x40000000
#define SMB_ACCESS_GENERIC_EXECUTE 0x20000000
#define SMB_ACCESS_GENERIC_ALL 0x10000000
//
// SMB file sharing access
//
#define SMB_FILE_SHARE_READ 0x00000001
#define SMB_FILE_SHARE_WRITE 0x00000002
#define SMB_FILE_SHARE_DELETE 0x00000004
//
// SMB file create disposition
//
#define SMB_OPEN_EXISTING 1 // Fail if not exist, open if exists
#define SMB_CREATE_NEW 2 // Create if not exist, fail if exist
#define SMB_OPEN_ALWAYS 3 // Create if not exist, open if exists
#define SMB_TRUNCATE_EXISTING 4 // Fail if not exist, truncate if exists
#define SMB_CREATE_ALWAYS 5 // Create if not exist, trunc if exist
//
// SMB impersonation levels
//
#define SMB_SECURITY_ANONYMOUS 0
#define SMB_SECURITY_IDENTIFICATION 1
#define SMB_SECURITY_IMPERSONATION 2
#define SMB_SECURITY_DELEGATION 3
//
// SMB filesystem information levels
//
#define SMB_INFO_ALLOCATION 1
#define SMB_INFO_VOLUME 2
#define SMB_QUERY_FS_VOLUME_INFO 0x102
#define SMB_QUERY_FS_SIZE_INFO 0x103
#define SMB_QUERY_FS_DEVICE_INFO 0x104
#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
//
// SMB file information levels
//
#define SMB_INFO_STANDARD 1
#define SMB_INFO_QUERY_EA_SIZE 2
#define SMB_INFO_QUERY_EAS_FROM_LIST 3
#define SMB_INFO_QUERY_ALL_EAS 4
#define SMB_INFO_IS_NAME_VALID 6
#define SMB_QUERY_FILE_BASIC_INFO 0x101
#define SMB_QUERY_FILE_STANDARD_INFO 0x102
#define SMB_QUERY_FILE_EA_INFO 0x103
#define SMB_QUERY_FILE_NAME_INFO 0x104
#define SMB_QUERY_FILE_ALL_INFO 0x107
#define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
#define SMB_QUERY_FILE_STREAM_INFO 0x109
#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
//
// FindFirst/FindNext flags
//
#define SMB_CLOSE_AFTER_FIRST (1 << 0)
#define SMB_CLOSE_IF_END (1 << 1)
#define SMB_REQUIRE_RESUME_KEY (1 << 2)
#define SMB_CONTINUE_BIT (1 << 3)
//
// Error Classes
//
#define SMB_SUCCESS 0 // The request was successful.
#define SMB_ERRDOS 0x01 // Error is from the core DOS operating system set.
#define SMB_ERRSRV 0x02 // Error is generated by the server network file manager.
#define SMB_ERRHRD 0x03 // Error is an hardware error.
#define SMB_ERRCMD 0xFF // Command was not in the "SMB" format.
//
// SMB X/Open error codes for the ERRdos error class
//
#define ERRbadfunc 1 // Invalid function (or system call)
#define ERRbadfile 2 // File not found (pathname error)
#define ERRbadpath 3 // Directory not found
#define ERRnofids 4 // Too many open files
#define ERRnoaccess 5 // Access denied
#define ERRbadfid 6 // Invalid fid
#define ERRbadmcb 7 // Memory control blocks destroyed
#define ERRnomem 8 // Out of memory
#define ERRbadmem 9 // Invalid memory block address
#define ERRbadenv 10 // Invalid environment
#define ERRbadformat 11 // Invalid format
#define ERRbadaccess 12 // Invalid open mode
#define ERRbaddata 13 // Invalid data (only from ioctl call)
#define ERRres 14 // Reserved
#define ERRbaddrive 15 // Invalid drive
#define ERRremcd 16 // Attempt to delete current directory
#define ERRdiffdevice 17 // Rename/move across different filesystems
#define ERRnofiles 18 // No more files found in file search
#define ERRbadshare 32 // Share mode on file conflict with open mode
#define ERRlock 33 // Lock request conflicts with existing lock
#define ERRfilexists 80 // File in operation already exists
#define ERRundocumented1 123 // Invalid name?? e.g. .tmp*
#define ERRbadpipe 230 // Named pipe invalid
#define ERRpipebusy 231 // All instances of pipe are busy
#define ERRpipeclosing 232 // Named pipe close in progress
#define ERRnotconnected 233 // No process on other end of named pipe
#define ERRmoredata 234 // More data to be returned
//
// Error codes for the ERRSRV class
//
#define ERRerror 1 // Non specific error code
#define ERRbadpw 2 // Bad password
#define ERRbadtype 3 // Reserved
#define ERRaccess 4 // No permissions to do the requested operation
#define ERRinvnid 5 // Tid invalid
#define ERRinvnetname 6 // Invalid servername
#define ERRinvdevice 7 // Invalid device
#define ERRqfull 49 // Print queue full
#define ERRqtoobig 50 // Queued item too big
#define ERRinvpfid 52 // Invalid print file in smb_fid
#define ERRsmbcmd 64 // Unrecognised command
#define ERRsrverror 65 // SMB server internal error
#define ERRfilespecs 67 // Fid and pathname invalid combination
#define ERRbadlink 68 // Reserved
#define ERRbadpermits 69 // Access specified for a file is not valid
#define ERRbadpid 70 // Reserved
#define ERRsetattrmode 71 // Attribute mode invalid
#define ERRpaused 81 // Message server paused
#define ERRmsgoff 82 // Not receiving messages
#define ERRnoroom 83 // No room for message
#define ERRrmuns 87 // Too many remote usernames
#define ERRtimeout 88 // Operation timed out
#define ERRnoresource 89 // No resources currently available for request.
#define ERRtoomanyuids 90 // Too many userids
#define ERRbaduid 91 // Bad userid
#define ERRuseMPX 250 // Temporarily unable to use raw mode, use MPX mode
#define ERRuseSTD 251 // Temporarily unable to use raw mode, use std.mode
#define ERRcontMPX 252 // Resume MPX mode
#define ERRnosupport 0xFFFF
//
// Error codes for the ERRHRD class
//
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -