summaryrefslogtreecommitdiff
path: root/source3/smbwrapper/smbw_dir.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-04 04:48:17 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-04 04:48:17 +0000
commitd71c04f927cbcbaae0708c1533748caac20ee5af (patch)
tree8d5a5aafb37aacaedba4322f1d62593354515e48 /source3/smbwrapper/smbw_dir.c
parent57a58f592b67a0ebf482f06315b9c546590126bf (diff)
downloadsamba-d71c04f927cbcbaae0708c1533748caac20ee5af.tar.gz
samba-d71c04f927cbcbaae0708c1533748caac20ee5af.tar.bz2
samba-d71c04f927cbcbaae0708c1533748caac20ee5af.zip
use dummy file descriptors opened on /dev/null to ensure that the smbw
file descriptor allocation order is identical to the kernels. (This used to be commit 60a683465647932f7241ba9f92443d5e5294e20b)
Diffstat (limited to 'source3/smbwrapper/smbw_dir.c')
-rw-r--r--source3/smbwrapper/smbw_dir.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source3/smbwrapper/smbw_dir.c b/source3/smbwrapper/smbw_dir.c
index 22da76eb17..c437a53e1f 100644
--- a/source3/smbwrapper/smbw_dir.c
+++ b/source3/smbwrapper/smbw_dir.c
@@ -175,17 +175,23 @@ int smbw_dir_open(const char *fname)
cur_dir = NULL;
- fd = bitmap_find(smbw_file_bmap, 0);
+ fd = open("/dev/null", O_WRONLY);
if (fd == -1) {
errno = EMFILE;
goto failed;
}
+ if (bitmap_query(smbw_file_bmap, fd)) {
+ DEBUG(0,("ERROR: fd used in smbw_dir_open\n"));
+ errno = EIO;
+ goto failed;
+ }
+
DLIST_ADD(smbw_dirs, dir);
bitmap_set(smbw_file_bmap, fd);
- dir->fd = fd + SMBW_FD_OFFSET;
+ dir->fd = fd;
dir->srv = srv;
dir->path = strdup(s);
@@ -241,7 +247,8 @@ int smbw_dir_close(int fd)
return -1;
}
- bitmap_clear(smbw_file_bmap, dir->fd - SMBW_FD_OFFSET);
+ bitmap_clear(smbw_file_bmap, dir->fd);
+ close(dir->fd);
DLIST_REMOVE(smbw_dirs, dir);