diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-10-04 04:48:17 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-10-04 04:48:17 +0000 |
commit | d71c04f927cbcbaae0708c1533748caac20ee5af (patch) | |
tree | 8d5a5aafb37aacaedba4322f1d62593354515e48 /source3/smbwrapper/smbw.c | |
parent | 57a58f592b67a0ebf482f06315b9c546590126bf (diff) | |
download | samba-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.c')
-rw-r--r-- | source3/smbwrapper/smbw.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c index d79131a8ea..11192bedd7 100644 --- a/source3/smbwrapper/smbw.c +++ b/source3/smbwrapper/smbw.c @@ -95,7 +95,7 @@ determine if a file descriptor is a smb one int smbw_fd(int fd) { if (smbw_busy) return 0; - return (fd >= SMBW_FD_OFFSET); + return smbw_file_bmap && bitmap_query(smbw_file_bmap, fd); } /***************************************************** @@ -523,16 +523,19 @@ int smbw_open(const char *fname, int flags, mode_t mode) goto failed; } file->srv = srv; - file->fd = bitmap_find(smbw_file_bmap, 0); - + file->fd = open("/dev/null", O_WRONLY); if (file->fd == -1) { errno = EMFILE; goto failed; } - bitmap_set(smbw_file_bmap, file->fd); + if (bitmap_query(smbw_file_bmap, file->fd)) { + DEBUG(0,("ERROR: fd used in smbw_open\n")); + errno = EIO; + goto failed; + } - file->fd += SMBW_FD_OFFSET; + bitmap_set(smbw_file_bmap, file->fd); DLIST_ADD(smbw_files, file); @@ -648,7 +651,8 @@ int smbw_close(int fd) } - bitmap_clear(smbw_file_bmap, file->fd - SMBW_FD_OFFSET); + bitmap_clear(smbw_file_bmap, file->fd); + close(file->fd); DLIST_REMOVE(smbw_files, file); |