mirror of
https://github.com/obarthel/amiga-smbfs.git
synced 2025-12-08 14:58:35 +00:00
Updated to version 1.136
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:
@@ -63,7 +63,6 @@ struct smb_dskattr
|
||||
*/
|
||||
struct smb_dirent
|
||||
{
|
||||
int opened; /* is it open on the fileserver? */
|
||||
word fileid; /* What id to handle a file with? */
|
||||
dword attr; /* Attribute fields, DOS value */
|
||||
|
||||
@@ -77,6 +76,9 @@ struct smb_dirent
|
||||
char * complete_path; /* Complete path, MS-DOS notation, with '\' */
|
||||
size_t complete_path_size; /* Number of bytes allocated for name */
|
||||
int len; /* Namelength. */
|
||||
|
||||
unsigned opened:1; /* is it open on the fileserver? */
|
||||
unsigned writable:1; /* was opened for read/write access? */
|
||||
};
|
||||
|
||||
#endif /* _LINUX_SMB_H */
|
||||
|
||||
+114
-10
@@ -840,6 +840,32 @@ smb_request_ok (struct smb_server *s, int command, int wct, int bcc, int * error
|
||||
return(smb_request_ok_with_payload (s, command, wct, bcc, NULL, NULL, 0, error_ptr));
|
||||
}
|
||||
|
||||
/* Try to reopen a file after the server has dropped the connection, or
|
||||
* was disconnected.
|
||||
*/
|
||||
static int
|
||||
reopen_entry(struct smb_server *server, struct smb_dirent *entry,int * error_ptr)
|
||||
{
|
||||
int result;
|
||||
|
||||
ASSERT( server != NULL && entry != NULL );
|
||||
|
||||
if(!entry->opened)
|
||||
{
|
||||
int ignored_error;
|
||||
|
||||
LOG (("trying to reopen file %s\n", entry->complete_path));
|
||||
|
||||
result = smb_proc_open (server, entry->complete_path, entry->len, entry->writable, FALSE, entry, error_ptr != NULL ? error_ptr : &ignored_error);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
/* smb_retry: This function should be called when smb_request_ok has
|
||||
* indicated an error. If the error was indicated because the
|
||||
* connection was killed, we try to reconnect. If smb_retry returns FALSE,
|
||||
@@ -1092,6 +1118,7 @@ smb_proc_open (struct smb_server *server, const char *pathname, int len, int wri
|
||||
entry->size = end_of_file_low;
|
||||
|
||||
entry->opened = TRUE;
|
||||
entry->writable = writable;
|
||||
|
||||
goto out;
|
||||
}
|
||||
@@ -1149,6 +1176,7 @@ smb_proc_open (struct smb_server *server, const char *pathname, int len, int wri
|
||||
entry->ctime = entry->atime = entry->mtime = entry->wtime = local2utc (DVAL (buf, smb_vwv2));
|
||||
entry->size = DVAL (buf, smb_vwv4);
|
||||
entry->opened = TRUE;
|
||||
entry->writable = writable;
|
||||
|
||||
out:
|
||||
|
||||
@@ -1210,9 +1238,21 @@ smb_proc_read (struct smb_server *server, struct smb_dirent *finfo, off_t offset
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
{
|
||||
LOG(("that didn't work.\n"));
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* The buffer format must be 1; smb_request_ok_with_payload() already checked this. */
|
||||
@@ -1255,7 +1295,12 @@ smb_proc_read_raw (struct smb_server *server, struct smb_dirent *finfo, off_t of
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
LOG(("that didn't work.\n"));
|
||||
else
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -1285,7 +1330,12 @@ smb_proc_write (struct smb_server *server, struct smb_dirent *finfo, off_t offse
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
LOG(("that didn't work.\n"));
|
||||
else
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1388,9 +1438,21 @@ smb_proc_write_raw (struct smb_server *server, struct smb_dirent *finfo, off_t o
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
{
|
||||
LOG(("that didn't work.\n"));
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
num_bytes_written += len;
|
||||
@@ -1416,9 +1478,21 @@ smb_proc_write_raw (struct smb_server *server, struct smb_dirent *finfo, off_t o
|
||||
count += len;
|
||||
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
{
|
||||
LOG(("that didn't work.\n"));
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if(server->write_behind)
|
||||
@@ -1511,7 +1585,12 @@ smb_proc_writex (struct smb_server *server, struct smb_dirent *finfo, off_t offs
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
LOG(("that didn't work.\n"));
|
||||
else
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1565,7 +1644,12 @@ smb_proc_readx (struct smb_server *server, struct smb_dirent *finfo, off_t offse
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
LOG(("that didn't work.\n"));
|
||||
else
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1625,7 +1709,12 @@ smb_proc_lockingX (struct smb_server *server, struct smb_dirent *finfo, struct s
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,finfo,NULL) < 0)
|
||||
LOG(("that didn't work.\n"));
|
||||
else
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -2995,7 +3084,17 @@ smb_set_file_information(struct smb_server *server, struct smb_dirent *entry, co
|
||||
if((*error_ptr) != error_check_smb_error)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,entry,NULL) < 0)
|
||||
{
|
||||
LOG(("that didn't work.\n"));
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
goto out;
|
||||
@@ -3077,7 +3176,12 @@ smb_proc_setattrE (struct smb_server *server, word fid, struct smb_dirent *new_e
|
||||
if (result < 0)
|
||||
{
|
||||
if (smb_retry (server))
|
||||
goto retry;
|
||||
{
|
||||
if(reopen_entry(server,new_entry,NULL) < 0)
|
||||
LOG(("that didn't work.\n"));
|
||||
else
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -56,8 +56,8 @@ struct smba_file
|
||||
struct smb_dirent dirent;
|
||||
ULONG attr_time; /* time when dirent was read */
|
||||
dircache_t * dircache; /* content cache for directories */
|
||||
unsigned attr_dirty:1; /* attribute cache is dirty */
|
||||
unsigned is_valid:1; /* server was down, entry removed, ... */
|
||||
unsigned attr_dirty:1; /* attribute cache is dirty */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -1461,8 +1461,8 @@ smb_invalidate_all_inodes (struct smb_server *server)
|
||||
f->node.mln_Succ != NULL;
|
||||
f = (smba_file_t *)f->node.mln_Succ)
|
||||
{
|
||||
f->dirent.opened = FALSE;
|
||||
f->is_valid = FALSE;
|
||||
f->dirent.opened = FALSE;
|
||||
f->is_valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 135
|
||||
#define DATE "21.5.2018"
|
||||
#define VERS "smbfs 1.135"
|
||||
#define VSTRING "smbfs 1.135 (21.5.2018)\r\n"
|
||||
#define VERSTAG "\0$VER: smbfs 1.135 (21.5.2018)"
|
||||
#define REVISION 136
|
||||
#define DATE "22.5.2018"
|
||||
#define VERS "smbfs 1.136"
|
||||
#define VSTRING "smbfs 1.136 (22.5.2018)\r\n"
|
||||
#define VERSTAG "\0$VER: smbfs 1.136 (22.5.2018)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
135
|
||||
136
|
||||
|
||||
@@ -834,6 +834,7 @@ smb_release (struct smb_server *server)
|
||||
int
|
||||
smb_connect (struct smb_server *server, int * error_ptr)
|
||||
{
|
||||
int enabled = TRUE;
|
||||
int result;
|
||||
|
||||
ASSERT( server != NULL );
|
||||
@@ -969,6 +970,9 @@ smb_connect (struct smb_server *server, int * error_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable socket keepalives, for good measure. */
|
||||
setsockopt(server->mount_data.fd, SOL_SOCKET, SO_KEEPALIVE, &enabled, sizeof(enabled));
|
||||
|
||||
/* Configure the send/receive timeout (in seconds)? */
|
||||
if(server->timeout > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user