Expand description
Raw Rust bindings to Samba’s libsmbclient library.
This crate mirrors the native C types and functions. Most callers should use the safe
pavao crate instead.
§Safety
The bindings do not validate pointers, lifetimes, buffer lengths, context state, or native
return values. Callers must uphold the corresponding libsmbclient C API contracts.
libsmbclient also shares process-wide parameter state, so separate contexts are not sufficient
for thread safety. Callers must serialize all raw native activity with one process-wide lock.
These bindings do not coordinate with Pavão’s safe-wrapper lock; raw calls must never race a
Pavão operation or any other raw libsmbclient call.
§Callback contracts
Unless an alias says otherwise, callbacks require a live, initialized context; every file or
directory handle must be live and belong to that context; C strings must be NUL-terminated and
readable for the call; and buffers must be valid for the supplied size. File and directory
operation callbacks generally return -1 or null with errno set on failure. Server-cache
callbacks instead return one on failure and do not promise an errno value. Callback
implementations must not unwind across the C ABI boundary.
Directory-entry pointers are borrowed from libsmbclient. They may be invalidated by the next
read on the same directory or when the directory is closed, so callers must copy needed data.
§Feature flags
| name | description | default |
|---|---|---|
abi-0-6 | Require libsmbclient ABI 0.6 or newer. | |
abi-0-8 | Require libsmbclient ABI 0.8 or newer. | |
vendored | Build the bundled Samba source instead of using the system library. |
Structs§
- libsmb_
file_ info - Extended directory-entry metadata returned by
libsmbclient. - print_
job_ info - Information about a queued SMB print job.
- smbc_
dirent - A directory entry returned by
libsmbclient. - smbc_
notify_ callback_ action - A single directory notification action reported by
libsmbclient.
Enums§
- _SMBCCTX
- Opaque native SMB client context.
- _SMBCFILE
- Opaque native SMB file or directory handle.
- _SMBCSRV
- Opaque native SMB server handle.
Constants§
- SMBC_
BASE_ FD - Smallest file descriptor returned by
libsmbclient. - SMBC_
COMMS_ SHARE - Directory-entry type for an SMB communications share.
- SMBC_
DIR - Directory-entry type for an SMB directory.
- SMBC_
DOS_ MODE_ ARCHIVE - DOS attribute bit for archived files.
- SMBC_
DOS_ MODE_ DIRECTORY - DOS attribute bit for directories.
- SMBC_
DOS_ MODE_ HIDDEN - DOS attribute bit for hidden files.
- SMBC_
DOS_ MODE_ READONLY - DOS attribute bit for read-only files.
- SMBC_
DOS_ MODE_ SYSTEM - DOS attribute bit for system files.
- SMBC_
DOS_ MODE_ VOLUME_ ID - DOS attribute bit for volume identifiers.
- SMBC_
ENCRYPTLEVEL_ DEFAULT - Default SMB encryption policy.
- SMBC_
ENCRYPTLEVEL_ NONE - SMB encryption is disabled.
- SMBC_
ENCRYPTLEVEL_ REQUEST - SMB encryption is requested when available.
- SMBC_
ENCRYPTLEVEL_ REQUIRE - SMB encryption is required.
- SMBC_
FILE - Directory-entry type for an SMB file.
- SMBC_
FILE_ SHARE - Directory-entry type for an SMB file share.
- SMBC_
IPC_ SHARE - Directory-entry type for an SMB IPC share.
- SMBC_
LINK - Directory-entry type for an SMB symbolic link.
- SMBC_
NOTIFY_ ACTION_ ADDED - Notification action for an added entry.
- SMBC_
NOTIFY_ ACTION_ ADDED_ STREAM - Notification action for an added stream.
- SMBC_
NOTIFY_ ACTION_ MODIFIED - Notification action for a modified entry.
- SMBC_
NOTIFY_ ACTION_ MODIFIED_ STREAM - Notification action for a modified stream.
- SMBC_
NOTIFY_ ACTION_ NEW_ NAME - Notification action for a new entry name.
- SMBC_
NOTIFY_ ACTION_ OLD_ NAME - Notification action for an old entry name.
- SMBC_
NOTIFY_ ACTION_ REMOVED - Notification action for a removed entry.
- SMBC_
NOTIFY_ ACTION_ REMOVED_ STREAM - Notification action for a removed stream.
- SMBC_
NOTIFY_ CHANGE_ ATTRIBUTES - Notification filter for attribute changes.
- SMBC_
NOTIFY_ CHANGE_ CREATION - Notification filter for creation-time changes.
- SMBC_
NOTIFY_ CHANGE_ DIR_ NAME - Notification filter for directory-name changes.
- SMBC_
NOTIFY_ CHANGE_ EA - Notification filter for extended-attribute changes.
- SMBC_
NOTIFY_ CHANGE_ FILE_ NAME - Notification filter for file-name changes.
- SMBC_
NOTIFY_ CHANGE_ LAST_ ACCESS - Notification filter for last-access changes.
- SMBC_
NOTIFY_ CHANGE_ LAST_ WRITE - Notification filter for last-write changes.
- SMBC_
NOTIFY_ CHANGE_ SECURITY - Notification filter for security changes.
- SMBC_
NOTIFY_ CHANGE_ SIZE - Notification filter for size changes.
- SMBC_
NOTIFY_ CHANGE_ STREAM_ NAME - Notification filter for stream-name changes.
- SMBC_
NOTIFY_ CHANGE_ STREAM_ SIZE - Notification filter for stream-size changes.
- SMBC_
NOTIFY_ CHANGE_ STREAM_ WRITE - Notification filter for stream-write changes.
- SMBC_
PRINTER_ SHARE - Directory-entry type for an SMB printer share.
- SMBC_
SERVER - Directory-entry type for an SMB server.
- SMBC_
SHAREMODE_ DENY_ ALL - Share mode that denies all access sharing.
- SMBC_
SHAREMODE_ DENY_ DOS - Share mode that denies DOS compatibility access.
- SMBC_
SHAREMODE_ DENY_ FCB - Share mode that denies file-control-block sharing.
- SMBC_
SHAREMODE_ DENY_ NONE - Share mode that allows all sharing.
- SMBC_
SHAREMODE_ DENY_ READ - Share mode that denies read sharing.
- SMBC_
SHAREMODE_ DENY_ WRITE - Share mode that denies write sharing.
- SMBC_
VFS_ FEATURE_ CASE_ INSENSITIVE - VFS feature indicating case-insensitive path handling.
- SMBC_
VFS_ FEATURE_ DFS - VFS feature indicating DFS support.
- SMBC_
VFS_ FEATURE_ NO_ UNIXCIFS - VFS feature indicating the absence of Unix CIFS extensions.
- SMBC_
VFS_ FEATURE_ RDONLY - VFS feature indicating a read-only filesystem.
- SMBC_
WORKGROUP - Directory-entry type for an SMB workgroup.
- SMBC_
XATTR_ FLAG_ CREATE - Extended-attribute flag that requires a new attribute.
- SMBC_
XATTR_ FLAG_ REPLACE - Extended-attribute flag that requires an existing attribute.
Functions§
- smbc_
free_ ⚠context - Attempts to free
contextand optionally shuts down its connections. - smbc_
getDebug ⚠ - Returns the native debug verbosity configured for
c. - smbc_
getFunction ⚠Chmod - Returns the mode-change callback installed in
c. - smbc_
getFunction ⚠Close - Returns the file-close callback installed in
c. - smbc_
getFunction ⚠Closedir - Returns the directory-close callback installed in
c. - smbc_
getFunction ⚠Creat - Returns the file-creation callback installed in
c. - smbc_
getFunction ⚠Fstat - Returns the open-file metadata callback installed in
c. - smbc_
getFunction ⚠FstatVFS - Returns the open-file filesystem-statistics callback installed in
c. - smbc_
getFunction ⚠Fstatdir - Returns the directory-metadata callback installed in
c. - smbc_
getFunction ⚠Ftruncate - Returns the file-truncation callback installed in
c. - smbc_
getFunction ⚠Getdents - Returns the multiple-directory-entry callback installed in
c. - smbc_
getFunction ⚠Getxattr - Returns the extended-attribute read callback installed in
c. - smbc_
getFunction ⚠List Print Jobs - Returns the print-job listing callback installed in
c. - smbc_
getFunction ⚠Listxattr - Returns the extended-attribute listing callback installed in
c. - smbc_
getFunction ⚠Lseek - Returns the file-seek callback installed in
c. - smbc_
getFunction ⚠Lseekdir - Returns the directory-seek callback installed in
c. - smbc_
getFunction ⚠Mkdir - Returns the directory-creation callback installed in
c. - smbc_
getFunction ⚠Notify - Returns the directory-notification callback installed in
c. - smbc_
getFunction ⚠Open - Returns the file-open callback installed in
c. - smbc_
getFunction ⚠Open Print Job - Returns the print-job opening callback installed in
c. - smbc_
getFunction ⚠Opendir - Returns the directory-open callback installed in
c. - smbc_
getFunction ⚠Print File - Returns the file-printing callback installed in
c. - smbc_
getFunction ⚠Read - Returns the file-read callback installed in
c. - smbc_
getFunction ⚠Readdir - Returns the directory-read callback installed in
c. - smbc_
getFunction ⚠Readdir Plus - Returns the extended directory-read callback installed in
c. - smbc_
getFunction ⚠Removexattr - Returns the extended-attribute removal callback installed in
c. - smbc_
getFunction ⚠Rename - Returns the entry-rename callback installed in
c. - smbc_
getFunction ⚠Rmdir - Returns the directory-removal callback installed in
c. - smbc_
getFunction ⚠Setxattr - Returns the extended-attribute write callback installed in
c. - smbc_
getFunction ⚠Splice - Returns the file-splicing callback installed in
c. - smbc_
getFunction ⚠Stat - Returns the path-metadata callback installed in
c. - smbc_
getFunction ⚠StatVFS - Returns the filesystem-statistics callback installed in
c. - smbc_
getFunction ⚠Telldir - Returns the directory-position callback installed in
c. - smbc_
getFunction ⚠Unlink - Returns the file-removal callback installed in
c. - smbc_
getFunction ⚠Unlink Print Job - Returns the print-job removal callback installed in
c. - smbc_
getFunction ⚠Utimes - Returns the timestamp-update callback installed in
c. - smbc_
getFunction ⚠Write - Returns the file-write callback installed in
c. - smbc_
getNetbios ⚠Name - Returns the NetBIOS name configured for
c. - smbc_
getOption ⚠Browse MaxLmb Count - Returns the maximum local master browser query count configured for
c. - smbc_
getOption ⚠Case Sensitive - Returns whether path matching is case-sensitive for
c. - smbc_
getOption ⚠Debug ToStderr - Returns whether native debug output is written to standard error for
c. - smbc_
getOption ⚠Fallback After Kerberos - Returns whether authentication falls back after Kerberos fails.
- smbc_
getOption ⚠Full Time Names - Returns whether full SMB time attribute names are enabled for
c. - smbc_
getOption ⚠NoAuto Anonymous Login - Returns whether automatic anonymous authentication is disabled.
- smbc_
getOption ⚠OneShare PerServer - Returns whether each server connection is restricted to one share.
- smbc_
getOption ⚠Open Share Mode - Returns the file-open sharing mode configured for
c. - smbc_
getOption ⚠SmbEncryption Level - Returns the SMB encryption policy configured for
c. - smbc_
getOption ⚠UrlEncode Readdir Entries - Returns whether URL encoding is enabled for directory-entry names in
c. - smbc_
getOption ⚠UseC Cache - Returns whether Kerberos uses the credential cache.
- smbc_
getOption ⚠UseKerberos - Returns whether Kerberos authentication is enabled for
c. - smbc_
getOption ⚠UseNT Hash - Returns whether the password configured for
cis an NT hash. - smbc_
getOption ⚠User Data - Returns the user data pointer stored in
c. - smbc_
getPort ⚠ - Returns the TCP port configured for
c, or zero for the native default. - smbc_
getTimeout ⚠ - Returns the timeout configured for
cin milliseconds. - smbc_
getUser ⚠ - Returns the username configured for
c. - smbc_
getWorkgroup ⚠ - Returns the workgroup configured for
c. - smbc_
init_ ⚠context - Initializes a newly allocated native SMB context.
- smbc_
new_ ⚠context - Allocates a new, uninitialized native SMB context.
- smbc_
setConfiguration ⚠ - Sets the global
libsmbclientconfiguration file used byc. - smbc_
setDebug ⚠ - Sets the native debug verbosity for
c. - smbc_
setFunction ⚠Auth Data With Context - Installs the context-aware authentication callback for
c. - smbc_
setLog ⚠Callback - Installs the callback used for native diagnostic messages.
- smbc_
setNetbios ⚠Name - Sets the NetBIOS name configured for
c. - smbc_
setOption ⚠Browse MaxLmb Count - Sets the maximum local master browser query count for
c. - smbc_
setOption ⚠Case Sensitive - Controls case-sensitive path matching for
c. - smbc_
setOption ⚠Debug ToStderr - Controls whether native debug output is written to standard error.
- smbc_
setOption ⚠Fallback After Kerberos - Controls fallback after Kerberos authentication fails.
- smbc_
setOption ⚠Full Time Names - Enables or disables full SMB time attribute names for
c. - smbc_
setOption ⚠NoAuto Anonymous Login - Prevents automatic anonymous authentication when enabled.
- smbc_
setOption ⚠OneShare PerServer - Restricts each server connection to one share when enabled.
- smbc_
setOption ⚠Open Share Mode - Sets the file-open sharing mode for
c. - smbc_
setOption ⚠Protocols - Sets the minimum and maximum SMB dialects offered during protocol negotiation.
- smbc_
setOption ⚠SmbEncryption Level - Sets the SMB encryption policy for
c. - smbc_
setOption ⚠UrlEncode Readdir Entries - Controls URL encoding of directory-entry names for
c. - smbc_
setOption ⚠UseC Cache - Controls whether Kerberos uses the credential cache.
- smbc_
setOption ⚠UseKerberos - Controls whether Kerberos authentication is attempted for
c. - smbc_
setOption ⚠UseNT Hash - Marks the password configured for
cas an NT hash when enabled. - smbc_
setOption ⚠User Data - Stores an opaque user data pointer in
c. - smbc_
setPort ⚠ - Sets the TCP port used by
c, where zero selects the native default. - smbc_
setTimeout ⚠ - Sets the timeout for
cin milliseconds. - smbc_
setUser ⚠ - Sets the username configured for
c. - smbc_
setWorkgroup ⚠ - Sets the workgroup configured for
c. - smbc_
set_ ⚠credentials_ with_ fallback - Sets fallback credentials used by
libsmbclientfor DFS referrals. - smbc_
version ⚠ - Returns the linked
libsmbclientversion string.
Type Aliases§
- SMBCCTX
- Native
libsmbclientcontext. - SMBCFILE
- Native SMB file or directory handle.
- SMBCSRV
- Native SMB server handle.
- smbc_
add_ cached_ srv_ fn - Optional callback that inserts a server into the connection cache.
- smbc_
bool - Native Boolean represented as a C integer.
- smbc_
check_ server_ fn - Optional callback that checks whether a cached server is still available.
- smbc_
chmod_ fn - Optional callback that changes a remote entry’s POSIX mode.
- smbc_
close_ fn - Optional callback that closes an open file handle.
- smbc_
closedir_ fn - Optional callback that closes an open directory handle.
- smbc_
creat_ fn - Optional callback that creates a remote file.
- smbc_
debug_ callback_ fn - Optional callback that receives native
libsmbclientdiagnostics. - smbc_
fstat_ fn - Optional callback that reads metadata from an open file handle.
- smbc_
fstatdir_ fn - Optional callback that reads metadata from an open directory handle.
- smbc_
fstatvfs_ fn - Optional callback that reads filesystem statistics from an open file handle.
- smbc_
ftruncate_ fn - Optional callback that changes the length of an open remote file.
- smbc_
get_ auth_ data_ fn - Optional callback that supplies authentication strings.
- smbc_
get_ auth_ data_ with_ context_ fn - Optional context-aware callback that supplies authentication strings.
- smbc_
get_ cached_ srv_ fn - Optional callback that looks up a server in the connection cache.
- smbc_
getdents_ fn - Optional callback that reads multiple directory entries into a buffer.
- smbc_
getxattr_ fn - Optional callback that reads a remote entry’s extended attribute.
- smbc_
list_ print_ job_ fn - Optional callback invoked for each print job in a queue.
- smbc_
list_ print_ jobs_ fn - Optional callback that enumerates jobs in a print queue.
- smbc_
listxattr_ fn - Optional callback that lists a remote entry’s extended attributes.
- smbc_
lseek_ fn - Optional callback that changes an open file’s offset.
- smbc_
lseekdir_ fn - Optional callback that changes a directory-stream offset.
- smbc_
mkdir_ fn - Optional callback that creates a remote directory.
- smbc_
notify_ callback_ fn - Callback invoked with directory notification actions.
- smbc_
notify_ fn - Optional callback that watches a directory for changes.
- smbc_
open_ fn - Optional callback that opens a remote file.
- smbc_
open_ print_ job_ fn - Optional callback that opens a new print job.
- smbc_
opendir_ fn - Optional callback that opens a remote directory.
- smbc_
print_ file_ fn - Optional callback that submits a remote file to a print queue.
- smbc_
purge_ cached_ fn - Optional callback that purges the connection cache.
- smbc_
read_ fn - Optional callback that reads bytes from an open remote file.
- smbc_
readdir_ fn - Optional callback that reads the next directory entry.
- smbc_
readdirplus_ fn - Optional callback that reads the next directory entry with metadata.
- smbc_
remove_ cached_ srv_ fn - Optional callback that removes a server from the connection cache.
- smbc_
remove_ unused_ server_ fn - Optional callback that removes an unused cached server.
- smbc_
removexattr_ fn - Optional callback that removes a remote entry’s extended attribute.
- smbc_
rename_ fn - Optional callback that renames or moves a remote entry.
- smbc_
rmdir_ fn - Optional callback that removes a remote directory.
- smbc_
setxattr_ fn - Optional callback that writes a remote entry’s extended attribute.
- smbc_
share_ mode - Native value for the
open_share_modeoption. - smbc_
smb_ encrypt_ level - Native value for the SMB transport encryption policy.
- smbc_
splice_ callback_ fn - Callback invoked while
libsmbclientsplices data between two open files. - smbc_
splice_ fn - Optional callback that splices data between two open remote files.
- smbc_
stat_ fn - Optional callback that reads metadata for a remote path.
- smbc_
statvfs_ fn - Optional callback that reads filesystem statistics for a remote path.
- smbc_
telldir_ fn - Optional callback that returns the current directory-stream offset.
- smbc_
unlink_ fn - Optional callback that removes a remote file.
- smbc_
unlink_ print_ job_ fn - Optional callback that removes a job from a print queue.
- smbc_
utimes_ fn - Optional callback that changes a remote entry’s access and modification times.
- smbc_
vfs_ feature - Bitmask describing filesystem capabilities reported by
libsmbclient. - smbc_
write_ fn - Optional callback that writes bytes to an open remote file.