Updated to version 1.140

Please keep in mind that this is still a development version and might surprise you (not necessarily in a good way).

Do not let me discourage you to build and test this version, although there will be some risks involved such as data corruption or loss of data.
This commit is contained in:
obarthel
2018-05-27 15:38:19 +02:00
parent ea486c36c9
commit 8e4d177607
10 changed files with 509 additions and 340 deletions
+8 -4
View File
@@ -67,15 +67,19 @@ struct smb_dirent
dword attr; /* Attribute fields, DOS value */
time_t atime, mtime,
wtime, ctime; /* Times, as seen by the server, normalized */
/* to UTC. The ugly conversion happens in */
/* proc.c */
wtime, ctime; /* Times, as seen by the server, normalized
* to UTC. The ugly conversion happens in
* proc.c
*/
dword size_low; /* File size (least significant 32 bits). */
dword size_high; /* File size (most significant 32 bits). */
char * complete_path; /* Complete path, MS-DOS notation, with '\' */
size_t complete_path_size; /* Number of bytes allocated for name */
size_t complete_path_size; /* Number of bytes allocated for name; this is
* used only by the directory reader and
* the cache.
*/
int len; /* Name length. */
+3 -3
View File
@@ -57,19 +57,19 @@ int smb_proc_read(struct smb_server *server, struct smb_dirent *finfo, off_t off
int smb_proc_write (struct smb_server *server, struct smb_dirent *finfo, off_t offset, long count, const char *data, int * error_ptr);
int smb_proc_writex (struct smb_server *server, struct smb_dirent *finfo, const QUAD * const offset, long count, const char *data, int * error_ptr);
int smb_proc_readx (struct smb_server *server, struct smb_dirent *finfo, const QUAD * const offset, long count, char *data, int * error_ptr);
int smb_proc_lockingX (struct smb_server *server, struct smb_dirent *finfo, struct smb_lkrng *locks, int num_entries, int mode, long timeout, int * error_ptr);
int smb_proc_lockingX (struct smb_server *server, struct smb_dirent *finfo, const struct smb_lkrng *locks, int num_entries, int mode, long timeout, int * error_ptr);
int smb_proc_create(struct smb_server *server, const char *path, int len, struct smb_dirent *entry, int * error_ptr);
int smb_proc_mv(struct smb_server *server, const char *opath, const int olen, const char *npath, const int nlen, int * error_ptr);
int smb_proc_mkdir(struct smb_server *server, const char *path, const int len, int * error_ptr);
int smb_proc_rmdir(struct smb_server *server, const char *path, const int len, int * error_ptr);
int smb_proc_unlink(struct smb_server *server, const char *path, const int len, int * error_ptr);
int smb_proc_trunc(struct smb_server *server, word fid, dword length, int * error_ptr);
int smb_proc_readdir(struct smb_server *server, char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr);
int smb_proc_readdir(struct smb_server *server, const char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr);
int smb_proc_getattr_core(struct smb_server *server, const char *path, int len, struct smb_dirent *entry, int * error_ptr);
int smb_proc_getattrE(struct smb_server *server, struct smb_dirent *entry, int * error_ptr);
int smb_query_path_information(struct smb_server *server, const char *path, int len, int fid, struct smb_dirent *entry, int * error_ptr);
int smb_set_file_information(struct smb_server *server, struct smb_dirent *entry, const QUAD * const size, int * error_ptr);
int smb_proc_setattr_core(struct smb_server *server, const char *path, int len, struct smb_dirent *new_finfo, int * error_ptr);
int smb_proc_setattr_core(struct smb_server *server, const char *path, int len, const struct smb_dirent *new_finfo, int * error_ptr);
int smb_proc_setattrE(struct smb_server *server, word fid, struct smb_dirent *new_entry, int * error_ptr);
int smb_proc_dskattr (struct smb_server *server, struct smb_dskattr *attr, int * error_ptr);
int smb_proc_connect(struct smb_server *server, int * error_ptr);
+31
View File
@@ -292,6 +292,20 @@
#define TRANSACT2_FINDNOTIFYNEXT 12
#define TRANSACT2_MKDIR 13 /* TRANS2_CREATE_DIRECTORY */
/* Basic SMB file attributes, such as used by TRANSACT2_FINDFIRST
* or SMB_COM_OPEN.
*/
#define SMB_FILE_ATTRIBUTE_NORMAL 0x0000
#define SMB_FILE_ATTRIBUTE_READONLY 0x0001
#define SMB_FILE_ATTRIBUTE_HIDDEN 0x0002
#define SMB_FILE_ATTRIBUTE_SYSTEM 0x0004
#define SMB_FILE_ATTRIBUTE_VOLUME 0x0008
#define SMB_FILE_ATTRIBUTE_DIRECTORY 0x0010
#define SMB_FILE_ATTRIBUTE_ARCHIVE 0x0020
#define SMB_SEARCH_ATTRIBUTE_READONLY 0x0100
#define SMB_SEARCH_ATTRIBUTE_HIDDEN 0x0200
#define SMB_SEARCH_ATTRIBUTE_SYSTEM 0x0400
/* Extended file attributes */
#define ATTR_READONLY 0x00000001
#define ATTR_HIDDEN 0x00000002
@@ -384,4 +398,21 @@
#define SMB_SET_FILE_BASIC_INFO 0x0101 /* NT LAN Manager */
#define SMB_SET_FILE_END_OF_FILE_INFO 0x0104 /* NT LAN Manager */
/* These are used with SMBopen */
#define SMB_OPEN_ACCESS_READ_ONLY 0x0000
#define SMB_OPEN_ACCESS_WRITE_ONLY 0x0001
#define SMB_OPEN_ACCESS_READ_WRITE 0x0002
#define SMB_OPEN_ACCESS_EXECUTE 0x0003
#define SMB_OPEN_SHARE_COMPATIBILITY_MODE 0x0000
#define SMB_OPEN_SHARE_DENY_EVERYTHING 0x0010
#define SMB_OPEN_SHARE_DENY_WRITE 0x0020
#define SMB_OPEN_SHARE_DENY_READ_EXECUTE 0x0030
#define SMB_OPEN_SHARE_DENY_NOTHING 0x0040
#define SMB_OPEN_LOCALITY_UNKNOWN 0x0000
#define SMB_OPEN_LOCALITY_SEQUENTIAL 0x0100
#define SMB_OPEN_LOCALITY_RANDOM 0x0200
#define SMB_OPEN_LOCALITY_MIXED 0x0300
#define SMB_OPEN_CACHE_DISABLED 0x1000
#define SMB_OPEN_WRITE_THROUGH_ENABLED 0x4000
#endif /* _SMBNO_H_ */
+245 -203
View File
File diff suppressed because it is too large Load Diff
+153 -93
View File
@@ -997,12 +997,35 @@ smb_proc_open (struct smb_server *server, const char *pathname, int len, int wri
int result;
char *p;
char *buf = server->transmit_buffer;
const word o_attr = aSYSTEM | aHIDDEN | aDIR;
int retry_read_only;
ENTER();
D(("pathname = '%s'", escape_name(pathname)));
/* Because the original code opened every file/directory in
* read/write mode, we emulate the same behaviour. Why this
* is done is hard to tell. Presumably, some directories need
* to be writable for modifications to take place within.
*
* If read access is requested, we start with write access
* and disable truncation just to be safe. If that attempt
* fails due to access rights issues, we try again with read
* access.
*/
if(writable)
{
retry_read_only = FALSE;
}
else
{
writable = TRUE;
retry_read_only = TRUE;
truncate_file = FALSE;
}
if (server->protocol >= PROTOCOL_NT1)
{
dword desired_access;
@@ -1019,41 +1042,41 @@ smb_proc_open (struct smb_server *server, const char *pathname, int len, int wri
ASSERT( smb_payload_size(server, 24, len+1) >= 0 );
if(writable)
{
SHOWMSG("write access required");
// desired_access = FILE_READ_DATA|FILE_WRITE_DATA|FILE_DELETE;
desired_access = GENERIC_READ|GENERIC_WRITE;
}
else
{
SHOWMSG("read access is sufficient");
// desired_access = FILE_READ_DATA;
desired_access = GENERIC_READ;
}
// desired_access |= FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES;
/* Allows others to read, write and delete the file just created.
* This may be useful if smbfs hangs or you need to restart your
* System and you need to clean up after the file you just
* created.
*/
share_access = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
if(writable && truncate_file)
{
create_disposition = FILE_OVERWRITE_IF;
create_options = FILE_NON_DIRECTORY_FILE | FILE_RANDOM_ACCESS;
}
else
{
create_disposition = FILE_OPEN;
create_options = 0;
}
while(TRUE)
{
if(writable)
{
SHOWMSG("write access required");
// desired_access = FILE_READ_DATA|FILE_WRITE_DATA|FILE_DELETE;
desired_access = GENERIC_READ|GENERIC_WRITE;
}
else
{
SHOWMSG("read access is sufficient");
// desired_access = FILE_READ_DATA;
desired_access = GENERIC_READ;
}
// desired_access |= FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES;
/* Allows others to read, write and delete the file just created.
* This may be useful if smbfs hangs or you need to restart your
* System and you need to clean up after the file you just
* created.
*/
share_access = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
if(writable && truncate_file)
{
create_disposition = FILE_OVERWRITE_IF;
create_options = FILE_NON_DIRECTORY_FILE | FILE_RANDOM_ACCESS;
}
else
{
create_disposition = FILE_OPEN;
create_options = 0;
}
data = smb_setup_header (server, SMBntcreateX, 24, len+1);
params = SMB_VWV (server->transmit_buffer);
@@ -1085,6 +1108,25 @@ smb_proc_open (struct smb_server *server, const char *pathname, int len, int wri
{
SHOWMSG("that didn't work; retrying");
/* Try again in read-only mode? */
if ((*error_ptr) == EACCES || ((*error_ptr) == error_check_smb_error && smb_errno(server->rcls,server->err) == EACCES))
{
if(retry_read_only)
{
SHOWMSG("retrying with read-only access");
retry_read_only = FALSE;
writable = FALSE;
continue;
}
else
{
goto out;
}
}
if (smb_retry (server))
continue;
else
@@ -1123,62 +1165,69 @@ smb_proc_open (struct smb_server *server, const char *pathname, int len, int wri
goto out;
}
ASSERT( smb_payload_size(server, 2, 2 + len) >= 0 );
SHOWMSG("using the old SMB_COM_OPEN");
retry:
p = smb_setup_header (server, SMBopen, 2, 2 + len);
WSET (buf, smb_vwv0, 0x42); /* read/write */
WSET (buf, smb_vwv1, o_attr);
smb_encode_ascii (p, pathname, len);
result = smb_request_ok (server, SMBopen, 7, 0, error_ptr);
if (result < 0)
else
{
if (smb_retry (server))
goto retry;
word access_and_share_modes;
if ((*error_ptr) == EACCES || ((*error_ptr) == error_check_smb_error && smb_errno(server->rcls,server->err) == EACCES))
ASSERT( smb_payload_size(server, 2, 2 + len) >= 0 );
SHOWMSG("using the old SMB_COM_OPEN");
while(TRUE)
{
/* Don't retry in read-only mode. */
if(writable)
goto out;
ASSERT( smb_payload_size(server, 2, 2 + len) >= 0 );
retry_read_only:
access_and_share_modes = SMB_OPEN_SHARE_DENY_NOTHING|SMB_OPEN_ACCESS_READ_WRITE;
else
access_and_share_modes = SMB_OPEN_SHARE_DENY_NOTHING|SMB_OPEN_ACCESS_READ_ONLY;
p = smb_setup_header (server, SMBopen, 2, 2 + len);
WSET (buf, smb_vwv0, 0x40); /* read only */
WSET (buf, smb_vwv1, o_attr);
WSET (buf, smb_vwv0, access_and_share_modes);
WSET (buf, smb_vwv1, SMB_FILE_ATTRIBUTE_HIDDEN|SMB_FILE_ATTRIBUTE_SYSTEM|SMB_FILE_ATTRIBUTE_DIRECTORY);
smb_encode_ascii (p, pathname, len);
result = smb_request_ok (server, SMBopen, 7, 0, error_ptr);
if (result < 0)
{
/* Try again in read-only mode? */
if ((*error_ptr) == EACCES || ((*error_ptr) == error_check_smb_error && smb_errno(server->rcls,server->err) == EACCES))
{
if(retry_read_only)
{
SHOWMSG("retrying with read-only access");
retry_read_only = FALSE;
writable = FALSE;
continue;
}
else
{
goto out;
}
}
if (smb_retry (server))
goto retry_read_only;
goto out;
continue;
else
goto out;
}
}
else
{
goto out;
}
}
/* We should now have data in vwv[0..6]. */
entry->fileid = WVAL (buf, smb_vwv0);
entry->attr = WVAL (buf, smb_vwv1);
entry->ctime = entry->atime = entry->mtime = entry->wtime = local2utc (DVAL (buf, smb_vwv2));
entry->size_low = DVAL (buf, smb_vwv4);
entry->size_high = 0;
entry->opened = TRUE;
entry->writable = writable;
break;
}
/* We should now have data in vwv[0..6]. */
entry->fileid = WVAL (buf, smb_vwv0);
entry->attr = WVAL (buf, smb_vwv1);
entry->ctime = entry->atime = entry->mtime = entry->wtime = local2utc (DVAL (buf, smb_vwv2));
entry->size_low = DVAL (buf, smb_vwv4);
entry->size_high = 0;
entry->opened = TRUE;
entry->writable = writable;
}
out:
@@ -1440,13 +1489,13 @@ smb_proc_readx (struct smb_server *server, struct smb_dirent *finfo, const QUAD
/* smb_proc_lockingX: We don't chain any further packets to the initial one */
int
smb_proc_lockingX (struct smb_server *server, struct smb_dirent *finfo, struct smb_lkrng *locks, int num_entries, int mode, long timeout, int * error_ptr)
smb_proc_lockingX (struct smb_server *server, struct smb_dirent *finfo, const struct smb_lkrng *locks, int num_entries, int mode, long timeout, int * error_ptr)
{
int result;
int num_locks, num_unlocks;
char *buf = server->transmit_buffer;
char *data;
struct smb_lkrng *p;
const struct smb_lkrng *p;
int i;
num_locks = num_unlocks = 0;
@@ -1692,7 +1741,7 @@ smb_proc_unlink (struct smb_server *server, const char *path, const int len, int
/* Allow for system and hidden files to be deleted, too. After
* all, we show these in the directory lists.
*/
WSET (buf, smb_vwv0, aSYSTEM | aHIDDEN);
WSET (buf, smb_vwv0, SMB_FILE_ATTRIBUTE_SYSTEM | SMB_FILE_ATTRIBUTE_HIDDEN);
smb_encode_ascii (p, path, len);
@@ -1738,8 +1787,8 @@ smb_proc_trunc (struct smb_server *server, word fid, dword length, int * error_p
return result;
}
static char *
smb_decode_dirent (char *p, struct smb_dirent *entry)
static int
smb_decode_dirent (const char *p, struct smb_dirent *entry)
{
size_t name_size;
@@ -1753,7 +1802,7 @@ smb_decode_dirent (char *p, struct smb_dirent *entry)
name_size = 13;
if(name_size > entry->complete_path_size-1)
name_size = entry->complete_path_size-1;
return(-1);
memcpy (entry->complete_path, p + 9, name_size);
@@ -1770,13 +1819,13 @@ smb_decode_dirent (char *p, struct smb_dirent *entry)
}
#endif /* DEBUG */
return p + 22;
return(0);
}
/* This routine is used to read in directory entries from the network.
Note that it is for short directory name seeks, i.e.: protocol < PROTOCOL_LANMAN2 */
static int
smb_proc_readdir_short (struct smb_server *server, char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr)
smb_proc_readdir_short (struct smb_server *server, const char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr)
{
char *p;
char *buf;
@@ -1822,7 +1871,7 @@ smb_proc_readdir_short (struct smb_server *server, char *path, int fpos, int cac
p = smb_setup_header (server, SMBsearch, 2, 5 + strlen (mask));
WSET (buf, smb_vwv0, entries_asked);
WSET (buf, smb_vwv1, aDIR);
WSET (buf, smb_vwv1, SMB_FILE_ATTRIBUTE_DIRECTORY);
p = smb_encode_ascii (p, mask, strlen (mask));
(*p++) = 5;
(void) smb_encode_word (p, 0);
@@ -1833,7 +1882,7 @@ smb_proc_readdir_short (struct smb_server *server, char *path, int fpos, int cac
p = smb_setup_header (server, SMBsearch, 2, 5 + SMB_STATUS_SIZE);
WSET (buf, smb_vwv0, entries_asked);
WSET (buf, smb_vwv1, aDIR);
WSET (buf, smb_vwv1, SMB_FILE_ATTRIBUTE_DIRECTORY);
p = smb_encode_ascii (p, "", 0);
(void) smb_encode_vblock (p, status, SMB_STATUS_SIZE);
}
@@ -1901,9 +1950,16 @@ smb_proc_readdir_short (struct smb_server *server, char *path, int fpos, int cac
}
else
{
p = smb_decode_dirent (p, current_entry);
if(smb_decode_dirent (p, current_entry) == 0)
{
current_entry += 1;
}
else
{
p += SMB_DIRINFO_SIZE;
current_entry += 1;
LOG (("skipped entry because name is too long; total_count = %ld, i = %ld, fpos = %ld\n", total_count, i, fpos));
}
}
total_count += 1;
@@ -2020,7 +2076,7 @@ smb_get_dirent_name(char *p,int level,char ** name_ptr,int * len_ptr)
/* interpret a long filename structure */
static int
smb_decode_long_dirent (char *p, struct smb_dirent *finfo, int level, int * entry_length_ptr)
smb_decode_long_dirent (const char *p, struct smb_dirent *finfo, int level, int * entry_length_ptr)
{
int success = TRUE;
@@ -2074,6 +2130,8 @@ smb_decode_long_dirent (char *p, struct smb_dirent *finfo, int level, int * entr
memcpy(finfo->complete_path, name, name_len);
finfo->complete_path[name_len] = '\0';
D(("name = '%s', length=%ld",escape_name(finfo->complete_path),name_len));
}
break;
@@ -2177,6 +2235,8 @@ smb_decode_long_dirent (char *p, struct smb_dirent *finfo, int level, int * entr
memcpy (finfo->complete_path, p, name_len);
finfo->complete_path[name_len] = '\0';
finfo->len = name_len;
D(("name = '%s', length=%ld",escape_name(finfo->complete_path),name_len));
}
break;
@@ -2197,7 +2257,7 @@ smb_decode_long_dirent (char *p, struct smb_dirent *finfo, int level, int * entr
}
static int
smb_proc_readdir_long (struct smb_server *server, char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr)
smb_proc_readdir_long (struct smb_server *server, const char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr)
{
int max_matches = 512; /* this should actually be based on the max_recv value */
@@ -2214,7 +2274,7 @@ smb_proc_readdir_long (struct smb_server *server, char *path, int fpos, int cach
int resp_data_len = 0;
int resp_param_len = 0;
int attribute = aSYSTEM | aHIDDEN | aDIR;
int attribute = SMB_FILE_ATTRIBUTE_SYSTEM | SMB_FILE_ATTRIBUTE_HIDDEN | SMB_FILE_ATTRIBUTE_DIRECTORY;
int result = 0;
int ff_searchcount;
@@ -2543,7 +2603,7 @@ smb_proc_readdir_long (struct smb_server *server, char *path, int fpos, int cach
}
int
smb_proc_readdir (struct smb_server *server, char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr)
smb_proc_readdir (struct smb_server *server, const char *path, int fpos, int cache_size, struct smb_dirent *entry, int * error_ptr)
{
int result;
@@ -2903,7 +2963,7 @@ smb_set_file_information(struct smb_server *server, struct smb_dirent *entry, co
* entry->mtime, to make touch work.
*/
int
smb_proc_setattr_core (struct smb_server *server, const char *path, int len, struct smb_dirent *new_finfo, int * error_ptr)
smb_proc_setattr_core (struct smb_server *server, const char *path, int len, const struct smb_dirent *new_finfo, int * error_ptr)
{
char *p;
char *buf = server->transmit_buffer;
+30 -30
View File
@@ -270,7 +270,7 @@ make_open (smba_file_t * f, int need_fid, int writable, int truncate, int * erro
goto out;
}
if ((f->dirent.attr & aDIR) == 0) /* a regular file */
if ((f->dirent.attr & SMB_FILE_ATTRIBUTE_DIRECTORY) == 0) /* a regular file */
{
if (f->server->server.protocol >= PROTOCOL_LANMAN2)
{
@@ -286,7 +286,7 @@ make_open (smba_file_t * f, int need_fid, int writable, int truncate, int * erro
}
else
{
LOG (("file '%s' is already open\n", escape_name(f->dirent.complete_path)));
LOG (("file '%s' is already open (fileid=0x%04lx)\n", escape_name(f->dirent.complete_path), f->dirent.fileid));
}
}
}
@@ -302,7 +302,7 @@ make_open (smba_file_t * f, int need_fid, int writable, int truncate, int * erro
}
else
{
LOG (("file '%s' is already open\n", escape_name(f->dirent.complete_path)));
LOG (("file '%s' is already open (fileid=0x%04lx)\n", escape_name(f->dirent.complete_path), f->dirent.fileid));
}
if (s->supports_E || !s->supports_E_known)
@@ -348,7 +348,7 @@ make_open (smba_file_t * f, int need_fid, int writable, int truncate, int * erro
/*****************************************************************************/
int
smba_open (smba_server_t * s, char *name, size_t name_size, int writable, int truncate, smba_file_t ** file, int * error_ptr)
smba_open (smba_server_t * s, char *name, int writable, int truncate, smba_file_t ** file, int * error_ptr)
{
smba_file_t *f;
int result;
@@ -367,7 +367,6 @@ smba_open (smba_server_t * s, char *name, size_t name_size, int writable, int tr
memset(f,0,sizeof(*f));
f->dirent.complete_path = name;
f->dirent.complete_path_size = name_size;
f->dirent.len = strlen (name);
f->server = s;
@@ -383,7 +382,7 @@ smba_open (smba_server_t * s, char *name, size_t name_size, int writable, int tr
AddTail ((struct List *)&s->open_files, (struct Node *)f);
s->num_open_files++;
LOG(("open succeeded, number of open files = %ld\n",s->num_open_files));
LOG(("file is ready (but hasn't actually been opened yet), number of open files = %ld\n",s->num_open_files));
(*file) = f;
f = NULL;
@@ -415,7 +414,7 @@ write_attr (smba_file_t * f, int * error_ptr)
}
else
{
result = make_open (f, open_dont_need_fid, open_read_only, open_dont_truncate, error_ptr);
result = make_open (f, open_dont_need_fid, open_writable, open_dont_truncate, error_ptr);
if (result < 0)
goto out;
@@ -445,8 +444,6 @@ smba_close (smba_file_t * f, int * error_ptr)
{
if(f != NULL)
{
LOG (("closing file '%s'\n", escape_name(f->dirent.complete_path)));
if(f->node.mln_Succ != NULL || f->node.mln_Pred != NULL)
Remove((struct Node *)f);
@@ -455,7 +452,8 @@ smba_close (smba_file_t * f, int * error_ptr)
if (f->dirent.opened)
{
LOG(("notifying the server that the file was closed"));
LOG (("closing file '%s' (fileid=0x%04lx)\n", escape_name(f->dirent.complete_path), f->dirent.fileid));
smb_proc_close (&f->server->server, f->dirent.fileid, f->dirent.mtime, error_ptr);
}
@@ -873,11 +871,11 @@ smba_getattr (smba_file_t * f, smba_stat_t * data, int * error_ptr)
f->attr_time = now;
}
data->is_dir = (f->dirent.attr & aDIR) != 0;
data->is_read_only = (f->dirent.attr & aRONLY) != 0;
data->is_hidden = (f->dirent.attr & aHIDDEN) != 0;
data->is_system = (f->dirent.attr & aSYSTEM) != 0;
data->is_changed_since_last_archive = (f->dirent.attr & aARCH) != 0;
data->is_dir = (f->dirent.attr & SMB_FILE_ATTRIBUTE_DIRECTORY) != 0;
data->is_read_only = (f->dirent.attr & SMB_FILE_ATTRIBUTE_READONLY) != 0;
data->is_hidden = (f->dirent.attr & SMB_FILE_ATTRIBUTE_HIDDEN) != 0;
data->is_system = (f->dirent.attr & SMB_FILE_ATTRIBUTE_SYSTEM) != 0;
data->is_changed_since_last_archive = (f->dirent.attr & SMB_FILE_ATTRIBUTE_ARCHIVE) != 0;
data->size_low = f->dirent.size_low;
data->size_high = f->dirent.size_high;
@@ -923,14 +921,14 @@ smba_setattr (smba_file_t * f, const smba_stat_t * data, const QUAD * const size
attrs = f->dirent.attr;
if (data->is_read_only)
attrs |= aRONLY;
attrs |= SMB_FILE_ATTRIBUTE_READONLY;
else
attrs &= ~aRONLY;
attrs &= ~SMB_FILE_ATTRIBUTE_READONLY;
if (data->is_changed_since_last_archive)
attrs |= aARCH;
attrs |= SMB_FILE_ATTRIBUTE_ARCHIVE;
else
attrs &= ~aARCH;
attrs &= ~SMB_FILE_ATTRIBUTE_ARCHIVE;
if(f->dirent.attr != attrs)
{
@@ -1059,11 +1057,11 @@ smba_readdir (smba_file_t * f, long offs, void *d, smba_callback_t callback, int
LOG (("delivering '%s', cache_index=%ld, eof=%ld\n", escape_name(f->dircache->cache[o].complete_path), cache_index, eof));
data.is_dir = (f->dircache->cache[o].attr & aDIR) != 0;
data.is_read_only = (f->dircache->cache[o].attr & aRONLY) != 0;
data.is_hidden = (f->dircache->cache[o].attr & aHIDDEN) != 0;
data.is_system = (f->dircache->cache[o].attr & aSYSTEM) != 0;
data.is_changed_since_last_archive = (f->dircache->cache[o].attr & aARCH) != 0;
data.is_dir = (f->dircache->cache[o].attr & SMB_FILE_ATTRIBUTE_DIRECTORY) != 0;
data.is_read_only = (f->dircache->cache[o].attr & SMB_FILE_ATTRIBUTE_READONLY) != 0;
data.is_hidden = (f->dircache->cache[o].attr & SMB_FILE_ATTRIBUTE_HIDDEN) != 0;
data.is_system = (f->dircache->cache[o].attr & SMB_FILE_ATTRIBUTE_SYSTEM) != 0;
data.is_changed_since_last_archive = (f->dircache->cache[o].attr & SMB_FILE_ATTRIBUTE_ARCHIVE) != 0;
data.size_low = f->dircache->cache[o].size_low;
data.size_high = f->dircache->cache[o].size_high;
data.atime = f->dircache->cache[o].atime;
@@ -1149,7 +1147,7 @@ smba_create (smba_file_t * dir, const char *name, int * error_ptr)
size_t len;
int result;
result = make_open (dir, open_dont_need_fid, open_read_only, open_dont_truncate, error_ptr);
result = make_open (dir, open_dont_need_fid, open_writable, open_dont_truncate, error_ptr);
if (result < 0)
goto out;
@@ -1208,7 +1206,7 @@ smba_mkdir (smba_file_t * dir, const char *name, int * error_ptr)
char *path = NULL;
int result;
result = make_open (dir, open_dont_need_fid, open_read_only, open_dont_truncate, error_ptr);
result = make_open (dir, open_dont_need_fid, open_writable, open_dont_truncate, error_ptr);
if (result < 0)
goto out;
@@ -1409,6 +1407,7 @@ smba_cleanup_dircache(struct smba_server * server)
static int
smba_setup_dircache (struct smba_server * server,int cache_size, int * error_ptr)
{
const int complete_path_size = SMB_MAXNAMELEN + 1;
dircache_t * the_dircache;
int result = -1;
int i;
@@ -1425,14 +1424,14 @@ smba_setup_dircache (struct smba_server * server,int cache_size, int * error_ptr
for (i = 0; i < the_dircache->cache_size; i++)
{
the_dircache->cache[i].complete_path = malloc (SMB_MAXNAMELEN + 1);
the_dircache->cache[i].complete_path = malloc (complete_path_size);
if(the_dircache->cache[i].complete_path == NULL)
{
(*error_ptr) = ENOMEM;
goto out;
}
the_dircache->cache[i].complete_path_size = SMB_MAXNAMELEN + 1;
the_dircache->cache[i].complete_path_size = complete_path_size;
}
server->dircache = the_dircache;
@@ -1754,6 +1753,7 @@ smba_get_dircache_size(struct smba_server * server)
int
smba_change_dircache_size(struct smba_server * server,int cache_size)
{
const int complete_path_size = SMB_MAXNAMELEN + 1;
dircache_t * new_cache;
dircache_t * old_dircache = server->dircache;
int result;
@@ -1791,14 +1791,14 @@ smba_change_dircache_size(struct smba_server * server,int cache_size)
/* Allocate memory for the file names. */
for(i = old_dircache->cache_size ; i < cache_size ; i++)
{
new_cache->cache[i].complete_path = malloc (SMB_MAXNAMELEN + 1);
new_cache->cache[i].complete_path = malloc (complete_path_size);
if(new_cache->cache[i].complete_path == NULL)
{
free_dircache(new_cache);
goto out;
}
new_cache->cache[i].complete_path_size = SMB_MAXNAMELEN + 1;
new_cache->cache[i].complete_path_size = complete_path_size;
}
/* Reuse the file name buffers allocated for the old cache. */
+1 -1
View File
@@ -85,7 +85,7 @@ typedef int (*smba_callback_t) (void *d, int fpos, int nextpos, char *name, int
/****************************************************************************/
int smba_open(smba_server_t *s, char *name, size_t name_size, int writable, int truncate, smba_file_t **file, int * error_ptr);
int smba_open(smba_server_t *s, char *name, int writable, int truncate, smba_file_t **file, int * error_ptr);
void smba_close(smba_file_t *f, int * error_ptr);
int smba_read(smba_file_t *f, char *data, long len, const QUAD * const offset, int * error_ptr);
int smba_write(smba_file_t *f, const char *data, long len, const QUAD * const offset, int * error_ptr);
+5 -5
View File
@@ -1,6 +1,6 @@
#define VERSION 1
#define REVISION 139
#define DATE "26.5.2018"
#define VERS "smbfs 1.139"
#define VSTRING "smbfs 1.139 (26.5.2018)\r\n"
#define VERSTAG "\0$VER: smbfs 1.139 (26.5.2018)"
#define REVISION 140
#define DATE "27.5.2018"
#define VERS "smbfs 1.140"
#define VSTRING "smbfs 1.140 (27.5.2018)\r\n"
#define VERSTAG "\0$VER: smbfs 1.140 (27.5.2018)"
+1 -1
View File
@@ -1 +1 @@
139
140