summaryrefslogtreecommitdiff
path: root/source3/smbwrapper/smbw.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-04 04:33:56 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-04 04:33:56 +0000
commit57a58f592b67a0ebf482f06315b9c546590126bf (patch)
treea3fdc435369865b8ef631f262e4d60d630515cd8 /source3/smbwrapper/smbw.c
parent977d6015564932410ff69e291b8c6eddeece334d (diff)
downloadsamba-57a58f592b67a0ebf482f06315b9c546590126bf.tar.gz
samba-57a58f592b67a0ebf482f06315b9c546590126bf.tar.bz2
samba-57a58f592b67a0ebf482f06315b9c546590126bf.zip
more smbw cleanups.
- cleaned up prototyping. Unfortunately we can't auto-prototype wrapped.c because it replaces system functions. - split stat functions into smbw_stat.c (This used to be commit 04e92e692e49234df6fbbfd07a33b315ed62f0de)
Diffstat (limited to 'source3/smbwrapper/smbw.c')
-rw-r--r--source3/smbwrapper/smbw.c155
1 files changed, 3 insertions, 152 deletions
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index 5a954d2fed..d79131a8ea 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -20,7 +20,6 @@
*/
#include "includes.h"
-#include "smbw.h"
#include "wrapper.h"
pstring smb_cwd;
@@ -461,54 +460,6 @@ struct smbw_file *smbw_file(int fd)
return NULL;
}
-
-/*****************************************************
-setup basic info in a stat structure
-*******************************************************/
-void smbw_setup_stat(struct stat *st, char *fname, size_t size, int mode)
-{
- ZERO_STRUCTP(st);
-
- if (IS_DOS_DIR(mode)) {
- st->st_mode = SMBW_DIR_MODE;
- } else {
- st->st_mode = SMBW_FILE_MODE;
- }
-
- st->st_size = size;
- st->st_blksize = 512;
- st->st_blocks = (size+511)/512;
- st->st_uid = getuid();
- st->st_gid = getgid();
- st->st_ino = smbw_inode(fname);
-}
-
-
-/*****************************************************
-try to do a QPATHINFO and if that fails then do a getatr
-this is needed because win95 sometimes refuses the qpathinfo
-*******************************************************/
-BOOL smbw_getatr(struct smbw_server *srv, char *path,
- uint32 *mode, size_t *size,
- time_t *c_time, time_t *a_time, time_t *m_time)
-{
- DEBUG(5,("sending qpathinfo\n"));
-
- if (cli_qpathinfo(&srv->cli, path, c_time, a_time, m_time,
- size, mode)) return True;
-
- DEBUG(5,("qpathinfo OK\n"));
-
- /* if this is NT then don't bother with the getatr */
- if (srv->cli.capabilities & CAP_NT_SMBS) return False;
-
- if (cli_getatr(&srv->cli, path, mode, size, m_time)) {
- a_time = c_time = m_time;
- return True;
- }
- return False;
-}
-
/*****************************************************
a wrapper for open()
*******************************************************/
@@ -604,107 +555,6 @@ int smbw_open(const char *fname, int flags, mode_t mode)
return -1;
}
-/*****************************************************
-a wrapper for fstat()
-*******************************************************/
-int smbw_fstat(int fd, struct stat *st)
-{
- struct smbw_file *file;
- time_t c_time, a_time, m_time;
- uint32 size;
- int mode;
-
- DEBUG(4,("%s\n", __FUNCTION__));
-
- smbw_busy++;
-
- file = smbw_file(fd);
- if (!file) {
- int ret = smbw_dir_fstat(fd, st);
- smbw_busy--;
- return ret;
- }
-
- if (!cli_qfileinfo(&file->srv->cli, file->cli_fd,
- &mode, &size, &c_time, &a_time, &m_time) &&
- !cli_getattrE(&file->srv->cli, file->cli_fd,
- &mode, &size, &c_time, &a_time, &m_time)) {
- errno = EINVAL;
- smbw_busy--;
- return -1;
- }
-
- smbw_setup_stat(st, file->fname, size, mode);
-
- st->st_atime = a_time;
- st->st_ctime = c_time;
- st->st_mtime = m_time;
- st->st_dev = file->srv->dev;
-
- DEBUG(4,("%s - OK\n", __FUNCTION__));
-
- smbw_busy--;
- return 0;
-}
-
-
-/*****************************************************
-a wrapper for stat()
-*******************************************************/
-int smbw_stat(const char *fname, struct stat *st)
-{
- struct smbw_server *srv;
- fstring server, share;
- pstring path;
- time_t m_time=0, a_time=0, c_time=0;
- size_t size=0;
- uint32 mode=0;
-
- DEBUG(4,("%s (%s)\n", __FUNCTION__, fname));
-
- if (!fname) {
- errno = EINVAL;
- return -1;
- }
-
- smbw_init();
-
- smbw_busy++;
-
- /* work out what server they are after */
- smbw_parse_path(fname, server, share, path);
-
- /* get a connection to the server */
- srv = smbw_server(server, share);
- if (!srv) {
- /* smbw_server sets errno */
- goto failed;
- }
-
- if (strcmp(share,"IPC$") == 0) {
- mode = aDIR | aRONLY;
- } else {
- if (!smbw_getatr(srv, path,
- &mode, &size, &c_time, &a_time, &m_time)) {
- errno = smbw_errno(&srv->cli);
- goto failed;
- }
- }
-
- smbw_setup_stat(st, path, size, mode);
-
- st->st_atime = time(NULL);
- st->st_ctime = m_time;
- st->st_mtime = m_time;
- st->st_dev = srv->dev;
-
- smbw_busy--;
- return 0;
-
- failed:
- smbw_busy--;
- return -1;
-}
/*****************************************************
a wrapper for read()
@@ -954,8 +804,9 @@ int smbw_rename(const char *oldname, const char *newname)
/*****************************************************
a wrapper for utime()
*******************************************************/
-int smbw_utime(const char *fname, struct utimbuf *buf)
+int smbw_utime(const char *fname, void *buf)
{
+ struct utimbuf *tbuf = (struct utimbuf *)buf;
struct smbw_server *srv;
fstring server, share;
pstring path;
@@ -987,7 +838,7 @@ int smbw_utime(const char *fname, struct utimbuf *buf)
goto failed;
}
- if (!cli_setatr(&srv->cli, path, mode, buf->modtime)) {
+ if (!cli_setatr(&srv->cli, path, mode, tbuf->modtime)) {
errno = smbw_errno(&srv->cli);
goto failed;
}