summaryrefslogtreecommitdiff
path: root/source3/smbwrapper
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-24 08:08:05 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-24 08:08:05 +0000
commitfb556e14f3b47d5a1f465589084e8b30d84af8ca (patch)
tree90efd6b2e60d40552f23b481f08e69b5e9e24178 /source3/smbwrapper
parent4140f2bfc141ee9a91723d274344769f8b11a5f9 (diff)
downloadsamba-fb556e14f3b47d5a1f465589084e8b30d84af8ca.tar.gz
samba-fb556e14f3b47d5a1f465589084e8b30d84af8ca.tar.bz2
samba-fb556e14f3b47d5a1f465589084e8b30d84af8ca.zip
volker was concerned about unique inode numbers and smbsh. This set of
changes uses the unique index number from a SMB_QUERY_FILE_ALL_INFO to try to provide inode numbers. If it is 0 then use the hash of the filename as before. (This used to be commit 2565ccf9de9d5e80fdb5bcadbc7130faba386d95)
Diffstat (limited to 'source3/smbwrapper')
-rw-r--r--source3/smbwrapper/smbw.c4
-rw-r--r--source3/smbwrapper/smbw_dir.c12
-rw-r--r--source3/smbwrapper/smbw_stat.c34
3 files changed, 39 insertions, 11 deletions
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index 622581b7a6..eb156ce0ef 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -149,6 +149,7 @@ a crude inode number generator
*******************************************************/
ino_t smbw_inode(const char *name)
{
+ if (!*name) return 2;
return (ino_t)str_checksum(name);
}
@@ -1194,7 +1195,8 @@ off_t smbw_lseek(int fd, off_t offset, int whence)
break;
case SEEK_END:
if (!cli_qfileinfo(&file->srv->cli, file->f->cli_fd,
- NULL, &size, NULL, NULL, NULL) &&
+ NULL, &size, NULL, NULL, NULL,
+ NULL, NULL) &&
!cli_getattrE(&file->srv->cli, file->f->cli_fd,
NULL, &size, NULL, NULL, NULL)) {
errno = EINVAL;
diff --git a/source3/smbwrapper/smbw_dir.c b/source3/smbwrapper/smbw_dir.c
index d374d5f179..4d1e3cc179 100644
--- a/source3/smbwrapper/smbw_dir.c
+++ b/source3/smbwrapper/smbw_dir.c
@@ -202,21 +202,31 @@ int smbw_dir_open(const char *fname)
if ((p=strstr(srv->server_name,"#1D"))) {
DEBUG(4,("doing NetServerEnum\n"));
*p = 0;
+ smbw_server_add(".",0,"");
+ smbw_server_add("..",0,"");
cli_NetServerEnum(&srv->cli, srv->server_name, SV_TYPE_ALL,
smbw_server_add);
*p = '#';
} else if (strcmp(srv->cli.dev,"IPC") == 0) {
DEBUG(4,("doing NetShareEnum\n"));
+ smbw_share_add(".",0,"");
+ smbw_share_add("..",0,"");
if (cli_RNetShareEnum(&srv->cli, smbw_share_add) < 0) {
errno = smbw_errno(&srv->cli);
goto failed;
}
} else if (strncmp(srv->cli.dev,"LPT",3) == 0) {
+ smbw_share_add(".",0,"");
+ smbw_share_add("..",0,"");
if (cli_print_queue(&srv->cli, smbw_printjob_add) < 0) {
errno = smbw_errno(&srv->cli);
goto failed;
}
} else {
+ if (strcmp(path,"\\") == 0) {
+ smbw_share_add(".",0,"");
+ smbw_share_add("..",0,"");
+ }
if (cli_list(&srv->cli, mask, aHIDDEN|aSYSTEM|aDIR,
smbw_dir_add) < 0) {
errno = smbw_errno(&srv->cli);
@@ -396,7 +406,7 @@ int smbw_chdir(const char *name)
if (strncmp(srv->cli.dev,"IPC",3) &&
strncmp(srv->cli.dev,"LPT",3) &&
!smbw_getatr(srv, path,
- &mode, NULL, NULL, NULL, NULL)) {
+ &mode, NULL, NULL, NULL, NULL, NULL)) {
errno = smbw_errno(&srv->cli);
goto failed;
}
diff --git a/source3/smbwrapper/smbw_stat.c b/source3/smbwrapper/smbw_stat.c
index adf973667f..443c898eb5 100644
--- a/source3/smbwrapper/smbw_stat.c
+++ b/source3/smbwrapper/smbw_stat.c
@@ -31,8 +31,6 @@ setup basic info in a stat structure
*******************************************************/
void smbw_setup_stat(struct stat *st, char *fname, size_t size, int mode)
{
- ZERO_STRUCTP(st);
-
st->st_mode = 0;
if (IS_DOS_DIR(mode)) {
@@ -51,7 +49,14 @@ void smbw_setup_stat(struct stat *st, char *fname, size_t size, int mode)
st->st_blocks = (size+511)/512;
st->st_uid = getuid();
st->st_gid = getgid();
- st->st_ino = smbw_inode(fname);
+ if (IS_DOS_DIR(mode)) {
+ st->st_nlink = 2;
+ } else {
+ st->st_nlink = 1;
+ }
+ if (st->st_ino == 0) {
+ st->st_ino = smbw_inode(fname);
+ }
}
@@ -61,13 +66,14 @@ 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)
+ time_t *c_time, time_t *a_time, time_t *m_time,
+ SMB_INO_T *ino)
{
DEBUG(4,("sending qpathinfo\n"));
if (!srv->no_pathinfo2 &&
cli_qpathinfo2(&srv->cli, path, c_time, a_time, m_time, NULL,
- size, mode)) return True;
+ size, mode, ino)) return True;
/* if this is NT then don't bother with the getatr */
if (srv->cli.capabilities & CAP_NT_SMBS) return False;
@@ -125,9 +131,12 @@ int smbw_fstat(int fd, struct stat *st)
time_t c_time, a_time, m_time;
size_t size;
uint32 mode;
+ SMB_INO_T ino = 0;
smbw_busy++;
+ ZERO_STRUCTP(st);
+
file = smbw_file(fd);
if (!file) {
int ret = smbw_dir_fstat(fd, st);
@@ -135,10 +144,9 @@ int smbw_fstat(int fd, struct stat *st)
return ret;
}
- DEBUG(4,("sending qfileinfo\n"));
-
if (!cli_qfileinfo(&file->srv->cli, file->f->cli_fd,
- &mode, &size, &c_time, &a_time, &m_time) &&
+ &mode, &size, &c_time, &a_time, &m_time, NULL,
+ &ino) &&
!cli_getattrE(&file->srv->cli, file->f->cli_fd,
&mode, &size, &c_time, &a_time, &m_time)) {
errno = EINVAL;
@@ -146,6 +154,8 @@ int smbw_fstat(int fd, struct stat *st)
return -1;
}
+ st->st_ino = ino;
+
smbw_setup_stat(st, file->f->fname, size, mode);
st->st_atime = a_time;
@@ -169,6 +179,9 @@ int smbw_stat(const char *fname, struct stat *st)
time_t m_time=0, a_time=0, c_time=0;
size_t size=0;
uint32 mode=0;
+ SMB_INO_T ino = 0;
+
+ ZERO_STRUCTP(st);
if (!fname) {
errno = EINVAL;
@@ -205,12 +218,15 @@ int smbw_stat(const char *fname, struct stat *st)
}
} else {
if (!smbw_getatr(srv, path,
- &mode, &size, &c_time, &a_time, &m_time)) {
+ &mode, &size, &c_time, &a_time, &m_time,
+ &ino)) {
errno = smbw_errno(&srv->cli);
goto failed;
}
}
+ st->st_ino = ino;
+
smbw_setup_stat(st, path, size, mode);
st->st_atime = a_time;