1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

use read() instead of fread() as fread() fails on redhat 6.

(This used to be commit b1025d499b)
This commit is contained in:
Luke Leighton 1999-08-18 00:01:00 +00:00
parent 0cf1de5fdd
commit 7a0595b234
2 changed files with 29 additions and 17 deletions

View File

@ -99,6 +99,8 @@ QUOTAOBJS=@QUOTAOBJS@
# object file lists
######################################################################
LIBSTATUS_OBJ = lib/util_status.o
LIB_OBJ = lib/charcnv.o lib/charset.o lib/debug.o lib/fault.o \
lib/getsmbpass.o lib/interface.o lib/kanji.o \
lib/md5.o lib/hmacmd5.o lib/md4.o \
@ -108,7 +110,7 @@ LIB_OBJ = lib/charcnv.o lib/charset.o lib/debug.o lib/fault.o \
lib/access.o lib/smbrun.o \
lib/bitmap.o lib/crc32.o lib/util_sid.o lib/snprintf.o \
lib/util_str.o lib/util_unistr.o \
lib/util_file.o lib/util_status.o mem_man/mem_man.o \
lib/util_file.o mem_man/mem_man.o \
lib/util_sock.o lib/unix_sec_ctxt.o
@ -191,7 +193,7 @@ PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/printing.o
SMBD_OBJ = $(SMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
$(RPC_SERVER_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \
$(LOCKING_OBJ) $(SAMPASSDB_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
$(PRINTING_OBJ) $(PROFILE_OBJ) $(LIB_OBJ)
$(LIBSTATUS_OBJ) $(PRINTING_OBJ) $(PROFILE_OBJ) $(LIB_OBJ)
NMBD_OBJ1 = nmbd/asyncdns.o nmbd/nmbd.o nmbd/nmbd_become_dmb.o \
@ -226,7 +228,7 @@ MAKE_SMBCODEPAGE_OBJ = utils/make_smbcodepage.o $(PARAM_OBJ) \
MAKE_PRINTERDEF_OBJ = utils/make_printerdef.o $(PARAM_OBJ) \
$(UBIQX_OBJ) $(LIB_OBJ)
STATUS_OBJ = utils/status.o $(LOCKING_OBJ) $(PARAM_OBJ) \
STATUS_OBJ = utils/status.o $(LIBSTATUS_OBJ) $(LOCKING_OBJ) $(PARAM_OBJ) \
$(UBIQX_OBJ) $(PROFILE_OBJ) $(LIB_OBJ)
TESTPARM_OBJ = utils/testparm.o \

View File

@ -30,9 +30,12 @@ parse the STATUS..LCK file. caller is responsible for freeing *crec.
BOOL get_connection_status(struct connect_record **crec,
uint32 *connection_count)
{
FILE *f;
int fd;
pstring fname;
int conn;
int num_recs;
struct connect_record *c;
int i;
if (crec == NULL || connection_count == NULL)
{
@ -44,18 +47,21 @@ BOOL get_connection_status(struct connect_record **crec,
trim_string(fname,"","/");
pstrcat(fname,"/STATUS..LCK");
f = sys_fopen(fname,"r");
if (!f) {
fd = sys_open(fname,O_RDONLY, 0);
if (fd == -1)
{
DEBUG(0,("Couldn't open status file %s\n",fname));
return False;
}
DEBUG(5,("Opened status file %s\n",fname));
conn=0;
(*crec) = NULL;
while (!feof(f))
num_recs = file_size(fname) / sizeof(*c);
DEBUG(5,("Opened status file %s, record count %d\n",fname, num_recs));
for (i = 0, conn = 0; i < num_recs; i++)
{
(*crec) = Realloc((*crec), (conn+1) * sizeof((*crec)[conn]));
if ((*crec) == NULL)
@ -63,18 +69,22 @@ BOOL get_connection_status(struct connect_record **crec,
DEBUG(0,("Realloc failed in get_connection_status\n"));
return False;
}
if (fread(&(*crec)[conn],sizeof((*crec)[conn]),1,f) != 1)
break;
if ((*crec)[conn].cnum == -1) continue;
if ( (*crec)[conn].magic == 0x280267 && process_exists((*crec)[conn].pid)
)
c = &((*crec)[conn]);
if (sys_lseek(fd,i*sizeof(*c),SEEK_SET) != i*sizeof(*c) ||
read(fd,c,sizeof(*c)) != sizeof(*c))
{
DEBUG(0,("unable to read a crec in get_connection_status\n"));
break;
}
DEBUG(10,("cnum:%u. pid: %d magic: %x\n",
c->cnum, c->pid, c->magic));
if ( c->magic == 0x280267 && process_exists(c->pid) )
{
DEBUG(10,("cnun : %u \n",(*crec)[conn].cnum));
conn++;
}
}
fclose(f);
close(fd);
(*connection_count)=conn;
return True;