summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-01-15 01:53:25 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-01-15 01:53:25 +0000
commit869f24e0b1915ec8d3e14f8850417474200e687e (patch)
tree135d2f510af69f43f0d7bc661c1f42eef72382c2
parent586c6276ec78c9ee276e3d01ba017db14c30e0ce (diff)
downloadsamba-869f24e0b1915ec8d3e14f8850417474200e687e.tar.gz
samba-869f24e0b1915ec8d3e14f8850417474200e687e.tar.bz2
samba-869f24e0b1915ec8d3e14f8850417474200e687e.zip
locking.c proto.h shmem.c smb.h status.c :
Changed shm_ prefixes to smb_shm_ prefixes as shm_ is a POSIX.4 prefix. Updated fd code in FAST_SHARE_MODE code to work with new fd indirection. quotas.c: Fixed #ifdef not on position zero. Jeremy. (jra@cygnus.com). (This used to be commit c9a9d56642cc34369a42f48a28116e466240d303)
-rw-r--r--source3/include/proto.h22
-rw-r--r--source3/include/smb.h6
-rw-r--r--source3/locking/locking.c87
-rw-r--r--source3/locking/shmem.c458
-rw-r--r--source3/smbd/quotas.c2
-rw-r--r--source3/utils/status.c33
6 files changed, 306 insertions, 302 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7f6c7d3892..8c7a8a47fe 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -702,17 +702,17 @@ int construct_reply(char *inbuf,char *outbuf,int size,int bufsize);
/*The following definitions come from shmem.c */
-BOOL shm_open( char *file_name, int size);
-BOOL shm_close( void );
-shm_offset_t shm_alloc(int size);
-BOOL shm_free(shm_offset_t offset);
-shm_offset_t shm_get_userdef_off(void);
-BOOL shm_set_userdef_off(shm_offset_t userdef_off);
-void * shm_offset2addr(shm_offset_t offset);
-shm_offset_t shm_addr2offset(void *addr);
-BOOL shm_lock(void);
-BOOL shm_unlock(void);
-BOOL shm_get_usage(int *bytes_free,
+BOOL smb_shm_open( char *file_name, int size);
+BOOL smb_shm_close( void );
+smb_shm_offset_t smb_shm_alloc(int size);
+BOOL smb_shm_free(smb_shm_offset_t offset);
+smb_shm_offset_t smb_shm_get_userdef_off(void);
+BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off);
+void * smb_shm_offset2addr(smb_shm_offset_t offset);
+smb_shm_offset_t shm_addr2offset(void *addr);
+BOOL smb_shm_lock(void);
+BOOL smb_shm_unlock(void);
+BOOL smb_shm_get_usage(int *bytes_free,
int *bytes_used,
int *bytes_overhead);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index bbb477f5f7..543cc73adb 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -55,8 +55,8 @@
typedef int BOOL;
/* offset in shared memory */
-typedef int shm_offset_t;
-#define NULL_OFFSET (shm_offset_t)(0)
+typedef int smb_shm_offset_t;
+#define NULL_OFFSET (smb_shm_offset_t)(0)
/*
@@ -419,7 +419,7 @@ struct interface
/* share mode record in shared memory */
typedef struct
{
- shm_offset_t next_offset; /* offset of next record in list in shared mem */
+ smb_shm_offset_t next_offset; /* offset of next record in list in shared mem */
int locking_version;
int share_mode;
struct timeval time;
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index d94cc9c35f..ce96aa01cf 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -114,7 +114,7 @@ BOOL start_share_mode_mgmt(void)
trim_string(shmem_file_name,"","/");
if (!*shmem_file_name) return(False);
strcat(shmem_file_name, "/SHARE_MEM_FILE");
- return shm_open(shmem_file_name, SHMEM_SIZE);
+ return smb_shm_open(shmem_file_name, SHMEM_SIZE);
}
@@ -123,7 +123,7 @@ BOOL start_share_mode_mgmt(void)
******************************************************************/
BOOL stop_share_mode_mgmt(void)
{
- return shm_close();
+ return smb_shm_close();
}
#else
@@ -191,9 +191,9 @@ int get_share_mode(int cnum,struct stat *sbuf,int *pid)
*pid = 0;
- if(!shm_lock()) return (0);
+ if(!smb_shm_lock()) return (0);
- scanner_p = (share_mode_record *)shm_offset2addr(shm_get_userdef_off());
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(smb_shm_get_userdef_off());
prev_p = scanner_p;
while(scanner_p)
{
@@ -205,13 +205,13 @@ int get_share_mode(int cnum,struct stat *sbuf,int *pid)
else
{
prev_p = scanner_p ;
- scanner_p = (share_mode_record *)shm_offset2addr(scanner_p->next_offset);
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(scanner_p->next_offset);
}
}
if(!found)
{
- shm_unlock();
+ smb_shm_unlock();
return (0);
}
@@ -219,13 +219,13 @@ int get_share_mode(int cnum,struct stat *sbuf,int *pid)
{
DEBUG(2,("Deleting old share mode record due to old locking version %d",scanner_p->locking_version));
if(prev_p == scanner_p)
- shm_set_userdef_off(scanner_p->next_offset);
+ smb_shm_set_userdef_off(scanner_p->next_offset);
else
prev_p->next_offset = scanner_p->next_offset;
- shm_free(shm_addr2offset(scanner_p));
+ smb_shm_free(smb_shm_addr2offset(scanner_p));
*pid = 0;
- shm_unlock();
+ smb_shm_unlock();
return (0);
}
@@ -241,16 +241,16 @@ int get_share_mode(int cnum,struct stat *sbuf,int *pid)
if (! *pid)
{
if(prev_p == scanner_p)
- shm_set_userdef_off(scanner_p->next_offset);
+ smb_shm_set_userdef_off(scanner_p->next_offset);
else
prev_p->next_offset = scanner_p->next_offset;
- shm_free(shm_addr2offset(scanner_p));
+ smb_shm_free(smb_shm_addr2offset(scanner_p));
}
if (*pid)
DEBUG(5,("Read share mode record mode 0x%X pid=%d\n",ret,*pid));
- if(!shm_unlock()) return (0);
+ if(!smb_shm_unlock()) return (0);
return(ret);
@@ -309,20 +309,20 @@ void del_share_mode(int fnum)
{
#if FAST_SHARE_MODES
struct stat st;
- time_t t=0;
+ struct timeval t;
int pid=0;
BOOL del = False;
share_mode_record *scanner_p;
share_mode_record *prev_p;
BOOL found = False;
+ t.tv_sec = t.tv_usec = 0;
+ if (fstat(Files[fnum].fd_ptr->fd,&st) != 0) return;
- if (fstat(Files[fnum].fd,&st) != 0) return;
-
- if (!shm_lock()) return;
+ if (!smb_shm_lock()) return;
- scanner_p = (share_mode_record *)shm_offset2addr(shm_get_userdef_off());
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(smb_shm_get_userdef_off());
prev_p = scanner_p;
while(scanner_p)
{
@@ -334,37 +334,39 @@ void del_share_mode(int fnum)
else
{
prev_p = scanner_p ;
- scanner_p = (share_mode_record *)shm_offset2addr(scanner_p->next_offset);
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(scanner_p->next_offset);
}
}
if(!found)
{
- shm_unlock();
+ smb_shm_unlock();
return;
}
- t = scanner_p->time;
+ t.tv_sec = scanner_p->time.tv_sec;
+ t.tv_usec = scanner_p->time.tv_usec;
pid = scanner_p->pid;
if( (scanner_p->locking_version != LOCKING_VERSION) || !pid || !process_exists(pid))
del = True;
- if (!del && t == Files[fnum].open_time && pid==(int)getpid())
+ if (!del && (memcmp(&t,&Files[fnum].open_time,sizeof(t)) == 0)
+ && pid==(int)getpid())
del = True;
if (del)
{
DEBUG(2,("Deleting share mode record\n"));
if(prev_p == scanner_p)
- shm_set_userdef_off(scanner_p->next_offset);
+ smb_shm_set_userdef_off(scanner_p->next_offset);
else
prev_p->next_offset = scanner_p->next_offset;
- shm_free(shm_addr2offset(scanner_p));
+ smb_shm_free(smb_shm_addr2offset(scanner_p));
}
- shm_unlock();
+ smb_shm_unlock();
return;
#else
@@ -418,30 +420,31 @@ BOOL set_share_mode(int fnum,int mode)
#if FAST_SHARE_MODES
int pid = (int)getpid();
struct stat st;
- shm_offset_t new_off;
+ smb_shm_offset_t new_off;
share_mode_record *new_p;
- if (fstat(Files[fnum].fd,&st) != 0) return(False);
+ if (fstat(Files[fnum].fd_ptr->fd,&st) != 0) return(False);
- if (!shm_lock()) return (False);
- new_off = shm_alloc(sizeof(share_mode_record) + strlen(Files[fnum].name) );
+ if (!smb_shm_lock()) return (False);
+ new_off = smb_shm_alloc(sizeof(share_mode_record) + strlen(Files[fnum].name) );
if (new_off == NULL_OFFSET) return (False);
- new_p = (share_mode_record *)shm_offset2addr(new_off);
+ new_p = (share_mode_record *)smb_shm_offset2addr(new_off);
new_p->locking_version = LOCKING_VERSION;
new_p->share_mode = mode;
- new_p->time = Files[fnum].open_time;
+ new_p->time.tv_sec = Files[fnum].open_time.tv_sec;
+ new_p->time.tv_usec = Files[fnum].open_time.tv_usec;
new_p->pid = pid;
new_p->st_dev = st.st_dev;
new_p->st_ino = st.st_ino;
strcpy(new_p->file_name,Files[fnum].name);
- new_p->next_offset = shm_get_userdef_off();
- shm_set_userdef_off(new_off);
+ new_p->next_offset = smb_shm_get_userdef_off();
+ smb_shm_set_userdef_off(new_off);
DEBUG(3,("Created share record for %s with mode 0x%X pid=%d\n",Files[fnum].name,mode,pid));
- if (!shm_unlock()) return (False);
+ if (!smb_shm_unlock()) return (False);
return(True);
#else
@@ -496,9 +499,9 @@ void clean_share_modes(void)
share_mode_record *prev_p;
int pid;
- if (!shm_lock()) return;
+ if (!smb_shm_lock()) return;
- scanner_p = (share_mode_record *)shm_offset2addr(shm_get_userdef_off());
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(smb_shm_get_userdef_off());
prev_p = scanner_p;
while(scanner_p)
{
@@ -509,28 +512,28 @@ void clean_share_modes(void)
DEBUG(2,("Deleting stale share mode record"));
if(prev_p == scanner_p)
{
- shm_set_userdef_off(scanner_p->next_offset);
- shm_free(shm_addr2offset(scanner_p));
- scanner_p = (share_mode_record *)shm_offset2addr(shm_get_userdef_off());
+ smb_shm_set_userdef_off(scanner_p->next_offset);
+ smb_shm_free(smb_shm_addr2offset(scanner_p));
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(smb_shm_get_userdef_off());
prev_p = scanner_p;
}
else
{
prev_p->next_offset = scanner_p->next_offset;
- shm_free(shm_addr2offset(scanner_p));
- scanner_p = (share_mode_record *)shm_offset2addr(prev_p->next_offset);
+ smb_shm_free(smb_shm_addr2offset(scanner_p));
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(prev_p->next_offset);
}
}
else
{
prev_p = scanner_p ;
- scanner_p = (share_mode_record *)shm_offset2addr(scanner_p->next_offset);
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(scanner_p->next_offset);
}
}
- shm_unlock();
+ smb_shm_unlock();
return;
#else
diff --git a/source3/locking/shmem.c b/source3/locking/shmem.c
index e17cf1aa8d..9f7b985e67 100644
--- a/source3/locking/shmem.c
+++ b/source3/locking/shmem.c
@@ -29,68 +29,68 @@
extern int DEBUGLEVEL;
-#define SHM_MAGIC 0x53484100
+#define SMB_SHM_MAGIC 0x53484100
/* = "SHM" in hex */
-#define SHM_VERSION 1
+#define SMB_SHM_VERSION 1
/* WARNING : offsets are used because mmap() does not guarantee that all processes have the
shared memory mapped to the same address */
-struct ShmHeader
+struct SmbShmHeader
{
- int shm_magic;
- int shm_version;
+ int smb_shm_magic;
+ int smb_shm_version;
int total_size; /* in bytes */
BOOL consistent;
- shm_offset_t first_free_off;
- shm_offset_t userdef_off; /* a userdefined offset. can be used to store root of tree or list */
- struct { /* a cell is a range of bytes of sizeof(struct ShmBlockDesc) size */
+ smb_shm_offset_t first_free_off;
+ smb_shm_offset_t userdef_off; /* a userdefined offset. can be used to store root of tree or list */
+ struct { /* a cell is a range of bytes of sizeof(struct SmbShmBlockDesc) size */
int cells_free;
int cells_used;
int cells_system; /* number of cells used as allocated block descriptors */
} statistics;
};
-#define SHM_NOT_FREE_OFF (-1)
-struct ShmBlockDesc
+#define SMB_SHM_NOT_FREE_OFF (-1)
+struct SmbShmBlockDesc
{
- shm_offset_t next; /* offset of next block in the free list or SHM_NOT_FREE_OFF when block in use */
+ smb_shm_offset_t next; /* offset of next block in the free list or SMB_SHM_NOT_FREE_OFF when block in use */
int size; /* user size in BlockDescSize units */
};
-#define EOList_Addr (struct ShmBlockDesc *)( 0 )
+#define EOList_Addr (struct SmbShmBlockDesc *)( 0 )
#define EOList_Off (NULL_OFFSET)
-#define CellSize sizeof(struct ShmBlockDesc)
+#define CellSize sizeof(struct SmbShmBlockDesc)
/* HeaderSize aligned on 8 byte boundary */
-#define AlignedHeaderSize ((sizeof(struct ShmHeader)+7) & ~7)
+#define AlignedHeaderSize ((sizeof(struct SmbShmHeader)+7) & ~7)
-static int shm_fd = -1;
-static pstring shm_processreg_name = "";
+static int smb_shm_fd = -1;
+static pstring smb_shm_processreg_name = "";
-static struct ShmHeader *shm_header_p = (struct ShmHeader *)0;
-static int shm_times_locked = 0;
+static struct SmbShmHeader *smb_shm_header_p = (struct SmbShmHeader *)0;
+static int smb_shm_times_locked = 0;
-static BOOL shm_register_process(char *processreg_file, pid_t pid, BOOL *other_processes)
+static BOOL smb_shm_register_process(char *processreg_file, pid_t pid, BOOL *other_processes)
{
- int shm_processes_fd = -1;
+ int smb_shm_processes_fd = -1;
int nb_read;
pid_t other_pid;
int free_slot = -1;
int erased_slot;
- shm_processes_fd = open(processreg_file, O_RDWR | O_CREAT, 0666);
- if ( shm_processes_fd < 0 )
+ smb_shm_processes_fd = open(processreg_file, O_RDWR | O_CREAT, 0666);
+ if ( smb_shm_processes_fd < 0 )
{
- DEBUG(0,("ERROR shm_register_process : processreg_file open failed with code %d\n",errno));
+ DEBUG(0,("ERROR smb_shm_register_process : processreg_file open failed with code %d\n",errno));
return False;
}
*other_processes = False;
- while ((nb_read = read(shm_processes_fd, &other_pid, sizeof(other_pid))) > 0)
+ while ((nb_read = read(smb_shm_processes_fd, &other_pid, sizeof(other_pid))) > 0)
{
if(other_pid)
{
@@ -99,46 +99,46 @@ static BOOL shm_register_process(char *processreg_file, pid_t pid, BOOL *other_p
else
{
/* erase old pid */
- DEBUG(2,("shm_register_process : erasing stale record for pid %d\n",other_pid));
+ DEBUG(2,("smb_shm_register_process : erasing stale record for pid %d\n",other_pid));
other_pid = (pid_t)0;
- erased_slot = lseek(shm_processes_fd, -sizeof(other_pid), SEEK_CUR);
- write(shm_processes_fd, &other_pid, sizeof(other_pid));
+ erased_slot = lseek(smb_shm_processes_fd, -sizeof(other_pid), SEEK_CUR);
+ write(smb_shm_processes_fd, &other_pid, sizeof(other_pid));
if(free_slot < 0)
free_slot = erased_slot;
}
}
else
if(free_slot < 0)
- free_slot = lseek(shm_processes_fd, -sizeof(other_pid), SEEK_CUR);
+ free_slot = lseek(smb_shm_processes_fd, -sizeof(other_pid), SEEK_CUR);
}
if (nb_read < 0)
{
- DEBUG(0,("ERROR shm_register_process : processreg_file read failed with code %d\n",errno));
- close(shm_processes_fd);
+ DEBUG(0,("ERROR smb_shm_register_process : processreg_file read failed with code %d\n",errno));
+ close(smb_shm_processes_fd);
return False;
}
if(free_slot < 0)
- free_slot = lseek(shm_processes_fd, 0, SEEK_END);
+ free_slot = lseek(smb_shm_processes_fd, 0, SEEK_END);
- DEBUG(2,("shm_register_process : writing record for pid %d at offset %d\n",pid,free_slot));
- lseek(shm_processes_fd, free_slot, SEEK_SET);
- if(write(shm_processes_fd, &pid, sizeof(pid)) < 0)
+ DEBUG(2,("smb_shm_register_process : writing record for pid %d at offset %d\n",pid,free_slot));
+ lseek(smb_shm_processes_fd, free_slot, SEEK_SET);
+ if(write(smb_shm_processes_fd, &pid, sizeof(pid)) < 0)
{
- DEBUG(0,("ERROR shm_register_process : processreg_file write failed with code %d\n",errno));
- close(shm_processes_fd);
+ DEBUG(0,("ERROR smb_shm_register_process : processreg_file write failed with code %d\n",errno));
+ close(smb_shm_processes_fd);
return False;
}
- close(shm_processes_fd);
+ close(smb_shm_processes_fd);
return True;
}
-static BOOL shm_unregister_process(char *processreg_file, pid_t pid)
+static BOOL smb_shm_unregister_process(char *processreg_file, pid_t pid)
{
int old_umask;
- int shm_processes_fd = -1;
+ int smb_shm_processes_fd = -1;
int nb_read;
pid_t other_pid;
int erased_slot;
@@ -146,26 +146,26 @@ static BOOL shm_unregister_process(char *processreg_file, pid_t pid)
old_umask = umask(0);
- shm_processes_fd = open(processreg_file, O_RDWR);
+ smb_shm_processes_fd = open(processreg_file, O_RDWR);
umask(old_umask);
- if ( shm_processes_fd < 0 )
+ if ( smb_shm_processes_fd < 0 )
{
- DEBUG(0,("ERROR shm_unregister_process : processreg_file open failed with code %d\n",errno));
+ DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file open failed with code %d\n",errno));
return False;
}
- while ((nb_read = read(shm_processes_fd, &other_pid, sizeof(other_pid))) > 0)
+ while ((nb_read = read(smb_shm_processes_fd, &other_pid, sizeof(other_pid))) > 0)
{
if(other_pid == pid)
{
/* erase pid */
- DEBUG(2,("shm_unregister_process : erasing record for pid %d\n",other_pid));
+ DEBUG(2,("smb_shm_unregister_process : erasing record for pid %d\n",other_pid));
other_pid = (pid_t)0;
- erased_slot = lseek(shm_processes_fd, -sizeof(other_pid), SEEK_CUR);
- if(write(shm_processes_fd, &other_pid, sizeof(other_pid)) < 0)
+ erased_slot = lseek(smb_shm_processes_fd, -sizeof(other_pid), SEEK_CUR);
+ if(write(smb_shm_processes_fd, &other_pid, sizeof(other_pid)) < 0)
{
- DEBUG(0,("ERROR shm_unregister_process : processreg_file write failed with code %d\n",errno));
- close(shm_processes_fd);
+ DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file write failed with code %d\n",errno));
+ close(smb_shm_processes_fd);
return False;
}
@@ -175,146 +175,146 @@ static BOOL shm_unregister_process(char *processreg_file, pid_t pid)
}
if (nb_read < 0)
{
- DEBUG(0,("ERROR shm_unregister_process : processreg_file read failed with code %d\n",errno));
- close(shm_processes_fd);
+ DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file read failed with code %d\n",errno));
+ close(smb_shm_processes_fd);
return False;
}
if(!found)
{
- DEBUG(0,("ERROR shm_unregister_process : couldn't find pid %d in file %s\n",pid,processreg_file));
- close(shm_processes_fd);
+ DEBUG(0,("ERROR smb_shm_unregister_process : couldn't find pid %d in file %s\n",pid,processreg_file));
+ close(smb_shm_processes_fd);
return False;
}
- close(shm_processes_fd);
+ close(smb_shm_processes_fd);
return True;
}
-static BOOL shm_validate_header(int size)
+static BOOL smb_shm_validate_header(int size)
{
- if( !shm_header_p )
+ if( !smb_shm_header_p )
{
/* not mapped yet */
- DEBUG(0,("ERROR shm_validate_header : shmem not mapped\n"));
+ DEBUG(0,("ERROR smb_shm_validate_header : shmem not mapped\n"));
return False;
}
- if(shm_header_p->shm_magic != SHM_MAGIC)
+ if(smb_shm_header_p->smb_shm_magic != SMB_SHM_MAGIC)
{
- DEBUG(0,("ERROR shm_validate_header : bad magic\n"));
+ DEBUG(0,("ERROR smb_shm_validate_header : bad magic\n"));
return False;
}
- if(shm_header_p->shm_version != SHM_VERSION)
+ if(smb_shm_header_p->smb_shm_version != SMB_SHM_VERSION)
{
- DEBUG(0,("ERROR shm_validate_header : bad version %X\n",shm_header_p->shm_version));
+ DEBUG(0,("ERROR smb_shm_validate_header : bad version %X\n",smb_shm_header_p->smb_shm_version));
return False;
}
- if(shm_header_p->total_size != size)
+ if(smb_shm_header_p->total_size != size)
{
- DEBUG(0,("ERROR shm_validate_header : shmem size mismatch (old = %d, new = %d)\n",shm_header_p->total_size,size));
+ DEBUG(0,("ERROR smb_shm_validate_header : shmem size mismatch (old = %d, new = %d)\n",smb_shm_header_p->total_size,size));
return False;
}
- if(!shm_header_p->consistent)
+ if(!smb_shm_header_p->consistent)
{
- DEBUG(0,("ERROR shm_validate_header : shmem not consistent\n"));
+ DEBUG(0,("ERROR smb_shm_validate_header : shmem not consistent\n"));
return False;
}
return True;
}
-static BOOL shm_initialize(int size)
+static BOOL smb_shm_initialize(int size)
{
- struct ShmBlockDesc * first_free_block_p;
+ struct SmbShmBlockDesc * first_free_block_p;
- DEBUG(2,("shm_initialize : initializing shmem file of size %d\n",size));
+ DEBUG(2,("smb_shm_initialize : initializing shmem file of size %d\n",size));
- if( !shm_header_p )
+ if( !smb_shm_header_p )
{
/* not mapped yet */
- DEBUG(0,("ERROR shm_initialize : shmem not mapped\n"));
+ DEBUG(0,("ERROR smb_shm_initialize : shmem not mapped\n"));
return False;
}
- shm_header_p->shm_magic = SHM_MAGIC;
- shm_header_p->shm_version = SHM_VERSION;
- shm_header_p->total_size = size;
- shm_header_p->first_free_off = AlignedHeaderSize;
- shm_header_p->userdef_off = NULL_OFFSET;
+ smb_shm_header_p->smb_shm_magic = SMB_SHM_MAGIC;
+ smb_shm_header_p->smb_shm_version = SMB_SHM_VERSION;
+ smb_shm_header_p->total_size = size;
+ smb_shm_header_p->first_free_off = AlignedHeaderSize;
+ smb_shm_header_p->userdef_off = NULL_OFFSET;
- first_free_block_p = (struct ShmBlockDesc *)shm_offset2addr(shm_header_p->first_free_off);
+ first_free_block_p = (struct SmbShmBlockDesc *)smb_shm_offset2addr(smb_shm_header_p->first_free_off);
first_free_block_p->next = EOList_Off;
first_free_block_p->size = ( size - AlignedHeaderSize - CellSize ) / CellSize ;
- shm_header_p->statistics.cells_free = first_free_block_p->size;
- shm_header_p->statistics.cells_used = 0;
- shm_header_p->statistics.cells_system = 1;
+ smb_shm_header_p->statistics.cells_free = first_free_block_p->size;
+ smb_shm_header_p->statistics.cells_used = 0;
+ smb_shm_header_p->statistics.cells_system = 1;
- shm_header_p->consistent = True;
+ smb_shm_header_p->consistent = True;
return True;
}
-static void shm_solve_neighbors(struct ShmBlockDesc *head_p )
+static void smb_shm_solve_neighbors(struct SmbShmBlockDesc *head_p )
{
- struct ShmBlockDesc *next_p;
+ struct SmbShmBlockDesc *next_p;
/* Check if head_p and head_p->next are neighbors and if so join them */
if ( head_p == EOList_Addr ) return ;
if ( head_p->next == EOList_Off ) return ;
- next_p = (struct ShmBlockDesc *)shm_offset2addr(head_p->next);
+ next_p = (struct SmbShmBlockDesc *)smb_shm_offset2addr(head_p->next);
if ( ( head_p + head_p->size + 1 ) == next_p)
{
head_p->size += next_p->size +1 ; /* adapt size */
head_p->next = next_p->next ; /* link out */
- shm_header_p->statistics.cells_free += 1;
- shm_header_p->statistics.cells_system -= 1;
+ smb_shm_header_p->statistics.cells_free += 1;
+ smb_shm_header_p->statistics.cells_system -= 1;
}
}
-BOOL shm_open( char *file_name, int size)
+BOOL smb_shm_open( char *file_name, int size)
{
int filesize;
BOOL created_new = False;
BOOL other_processes = True;
int old_umask;
- DEBUG(2,("shm_open : using shmem file %s to be of size %d\n",file_name,size));
+ DEBUG(2,("smb_shm_open : using shmem file %s to be of size %d\n",file_name,size));
old_umask = umask(0);
- shm_fd = open(file_name, O_RDWR | O_CREAT, 0666);
+ smb_shm_fd = open(file_name, O_RDWR | O_CREAT, 0666);
umask(old_umask);
- if ( shm_fd < 0 )
+ if ( smb_shm_fd < 0 )
{
- DEBUG(0,("ERROR shm_open : open failed with code %d\n",errno));
+ DEBUG(0,("ERROR smb_shm_open : open failed with code %d\n",errno));
return False;
}
- if (!shm_lock())
+ if (!smb_shm_lock())
{
- DEBUG(0,("ERROR shm_open : can't do shm_lock\n"));
+ DEBUG(0,("ERROR smb_shm_open : can't do smb_shm_lock\n"));
return False;
}
- if( (filesize = lseek(shm_fd, 0, SEEK_END)) < 0)
+ if( (filesize = lseek(smb_shm_fd, 0, SEEK_END)) < 0)
{
- DEBUG(0,("ERROR shm_open : lseek failed with code %d\n",errno));
- shm_unlock();
- close(shm_fd);
+ DEBUG(0,("ERROR smb_shm_open : lseek failed with code %d\n",errno));
+ smb_shm_unlock();
+ close(smb_shm_fd);
return False;
}
/* return the file offset to 0 to save on later seeks */
- lseek(shm_fd,0,SEEK_SET);
+ lseek(smb_shm_fd,0,SEEK_SET);
if (filesize == 0)
{
@@ -327,30 +327,30 @@ BOOL shm_open( char *file_name, int size)
*/
/* construct processreg file name */
- strcpy(shm_processreg_name, file_name);
- strcat(shm_processreg_name, ".processes");
+ strcpy(smb_shm_processreg_name, file_name);
+ strcat(smb_shm_processreg_name, ".processes");
- if (! shm_register_process(shm_processreg_name, getpid(), &other_processes))
+ if (! smb_shm_register_process(smb_shm_processreg_name, getpid(), &other_processes))
{
- shm_unlock();
- close(shm_fd);
+ smb_shm_unlock();
+ close(smb_shm_fd);
return False;
}
if (created_new || !other_processes)
{
/* we just created a new one, or are the first opener, lets set it size */
- if( ftruncate(shm_fd, size) <0)
+ if( ftruncate(smb_shm_fd, size) <0)
{
- DEBUG(0,("ERROR shm_open : ftruncate failed with code %d\n",errno));
- shm_unregister_process(shm_processreg_name, getpid());
- shm_unlock();
- close(shm_fd);
+ DEBUG(0,("ERROR smb_shm_open : ftruncate failed with code %d\n",errno));
+ smb_shm_unregister_process(smb_shm_processreg_name, getpid());
+ smb_shm_unlock();
+ close(smb_shm_fd);
return False;
}
/* paranoia */
- lseek(shm_fd,0,SEEK_SET);
+ lseek(smb_shm_fd,0,SEEK_SET);
filesize = size;
}
@@ -359,88 +359,88 @@ BOOL shm_open( char *file_name, int size)
{
/* the existing file has a different size and we are not the first opener.
Since another process is still using it, we will use the file size */
- DEBUG(0,("WARNING shm_open : filesize (%d) != expected size (%d), using filesize\n",filesize,size));
+ DEBUG(0,("WARNING smb_shm_open : filesize (%d) != expected size (%d), using filesize\n",filesize,size));
size = filesize;
}
- shm_header_p = (struct ShmHeader *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, shm_fd, 0);
- /* WARNING, shm_header_p can be different for different processes mapping the same file ! */
- if (shm_header_p == (struct ShmHeader *)(-1))
+ smb_shm_header_p = (struct SmbShmHeader *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, smb_shm_fd, 0);
+ /* WARNING, smb_shm_header_p can be different for different processes mapping the same file ! */
+ if (smb_shm_header_p == (struct SmbShmHeader *)(-1))
{
- DEBUG(0,("ERROR shm_open : mmap failed with code %d\n",errno));
- shm_unregister_process(shm_processreg_name, getpid());
- shm_unlock();
- close(shm_fd);
+ DEBUG(0,("ERROR smb_shm_open : mmap failed with code %d\n",errno));
+ smb_shm_unregister_process(smb_shm_processreg_name, getpid());
+ smb_shm_unlock();
+ close(smb_shm_fd);
return False;
}
if (created_new || !other_processes)
{
- shm_initialize(size);
+ smb_shm_initialize(size);
}
- else if (!shm_validate_header(size) )
+ else if (!smb_shm_validate_header(size) )
{
/* existing file is corrupt, samba admin should remove it by hand */
- DEBUG(0,("ERROR shm_open : corrupt shared mem file, remove it manually\n"));
- munmap((caddr_t)shm_header_p, size);
- shm_unregister_process(shm_processreg_name, getpid());
- shm_unlock();
- close(shm_fd);
+ DEBUG(0,("ERROR smb_shm_open : corrupt shared mem file, remove it manually\n"));
+ munmap((caddr_t)smb_shm_header_p, size);
+ smb_shm_unregister_process(smb_shm_processreg_name, getpid());
+ smb_shm_unlock();
+ close(smb_shm_fd);
return False;
}
- shm_unlock();
+ smb_shm_unlock();
return True;
}
-BOOL shm_close( void )
+BOOL smb_shm_close( void )
{
- DEBUG(2,("shm_close\n"));
- if(shm_times_locked > 0)
- DEBUG(0,("WARNING shm_close : shmem was still locked %d times\n",shm_times_locked));;
- if ( munmap((caddr_t)shm_header_p, shm_header_p->total_size) < 0)
+ DEBUG(2,("smb_shm_close\n"));
+ if(smb_shm_times_locked > 0)
+ DEBUG(0,("WARNING smb_shm_close : shmem was still locked %d times\n",smb_shm_times_locked));;
+ if ( munmap((caddr_t)smb_shm_header_p, smb_shm_header_p->total_size) < 0)
{
- DEBUG(0,("ERROR shm_close : munmap failed with code %d\n",errno));
+ DEBUG(0,("ERROR smb_shm_close : munmap failed with code %d\n",errno));
}
- shm_lock();
- shm_unregister_process(shm_processreg_name, getpid());
- shm_unlock();
+ smb_shm_lock();
+ smb_shm_unregister_process(smb_shm_processreg_name, getpid());
+ smb_shm_unlock();
- close(shm_fd);
+ close(smb_shm_fd);
- shm_fd = -1;
- shm_processreg_name[0] = '\0';
+ smb_shm_fd = -1;
+ smb_shm_processreg_name[0] = '\0';
- shm_header_p = (struct ShmHeader *)0;
- shm_times_locked = 0;
+ smb_shm_header_p = (struct SmbShmHeader *)0;
+ smb_shm_times_locked = 0;
return True;
}
-shm_offset_t shm_alloc(int size)
+smb_shm_offset_t smb_shm_alloc(int size)
{
unsigned num_cells ;
- struct ShmBlockDesc *scanner_p;
- struct ShmBlockDesc *prev_p;
- struct ShmBlockDesc *new_p;
- shm_offset_t result_offset;
+ struct SmbShmBlockDesc *scanner_p;
+ struct SmbShmBlockDesc *prev_p;
+ struct SmbShmBlockDesc *new_p;
+ smb_shm_offset_t result_offset;
- if( !shm_header_p )
+ if( !smb_shm_header_p )
{
/* not mapped yet */
- DEBUG(0,("ERROR shm_alloc : shmem not mapped\n"));
+ DEBUG(0,("ERROR smb_shm_alloc : shmem not mapped\n"));
return NULL_OFFSET;
}
- if( !shm_header_p->consistent)
+ if( !smb_shm_header_p->consistent)
{
- DEBUG(0,("ERROR shm_alloc : shmem not consistent\n"));
+ DEBUG(0,("ERROR smb_shm_alloc : shmem not consistent\n"));
return NULL_OFFSET;
}
@@ -449,25 +449,25 @@ shm_offset_t shm_alloc(int size)
num_cells = (size + CellSize -1) / CellSize;
/* set start of scan */
- prev_p = (struct ShmBlockDesc *)shm_offset2addr(shm_header_p->first_free_off);
+ prev_p = (struct SmbShmBlockDesc *)smb_shm_offset2addr(smb_shm_header_p->first_free_off);
scanner_p = prev_p ;
/* scan the free list to find a matching free space */
while ( ( scanner_p != EOList_Addr ) && ( scanner_p->size < num_cells ) )
{
prev_p = scanner_p;
- scanner_p = (struct ShmBlockDesc *)shm_offset2addr(scanner_p->next);
+ scanner_p = (struct SmbShmBlockDesc *)smb_shm_offset2addr(scanner_p->next);
}
/* at this point scanner point to a block header or to the end of the list */
if ( scanner_p == EOList_Addr )
{
- DEBUG(0,("ERROR shm_alloc : alloc of %d bytes failed, no free space found\n",size));
+ DEBUG(0,("ERROR smb_shm_alloc : alloc of %d bytes failed, no free space found\n",size));
return (NULL_OFFSET);
}
/* going to modify shared mem */
- shm_header_p->consistent = False;
+ smb_shm_header_p->consistent = False;
/* if we found a good one : scanner == the good one */
if ( scanner_p->size <= num_cells + 2 )
@@ -477,14 +477,14 @@ shm_offset_t shm_alloc(int size)
*/
if ( prev_p == scanner_p )
{
- shm_header_p->first_free_off = scanner_p->next ;
+ smb_shm_header_p->first_free_off = scanner_p->next ;
}
else
{
prev_p->next = scanner_p->next ;
}
- shm_header_p->statistics.cells_free -= scanner_p->size;
- shm_header_p->statistics.cells_used += scanner_p->size;
+ smb_shm_header_p->statistics.cells_free -= scanner_p->size;
+ smb_shm_header_p->statistics.cells_used += scanner_p->size;
}
else
{
@@ -493,166 +493,166 @@ shm_offset_t shm_alloc(int size)
new_p->size = scanner_p->size - num_cells - 1;
new_p->next = scanner_p->next;
scanner_p->size = num_cells;
- scanner_p->next = shm_addr2offset(new_p);
+ scanner_p->next = smb_shm_addr2offset(new_p);
if ( prev_p != scanner_p )
{
- prev_p->next = shm_addr2offset(new_p) ;
+ prev_p->next = smb_shm_addr2offset(new_p) ;
}
else
{
- shm_header_p->first_free_off = shm_addr2offset(new_p) ;
+ smb_shm_header_p->first_free_off = smb_shm_addr2offset(new_p) ;
}
- shm_header_p->statistics.cells_free -= num_cells+1;
- shm_header_p->statistics.cells_used += num_cells;
- shm_header_p->statistics.cells_system += 1;
+ smb_shm_header_p->statistics.cells_free -= num_cells+1;
+ smb_shm_header_p->statistics.cells_used += num_cells;
+ smb_shm_header_p->statistics.cells_system += 1;
}
- result_offset = shm_addr2offset( &(scanner_p[1]) );
- scanner_p->next = SHM_NOT_FREE_OFF ;
+ result_offset = smb_shm_addr2offset( &(scanner_p[1]) );
+ scanner_p->next = SMB_SHM_NOT_FREE_OFF ;
/* end modification of shared mem */
- shm_header_p->consistent = True;
+ smb_shm_header_p->consistent = True;
- DEBUG(2,("shm_alloc : request for %d bytes, allocated %d bytes at offset %d\n",size,scanner_p->size*CellSize,result_offset ));
+ DEBUG(2,("smb_shm_alloc : request for %d bytes, allocated %d bytes at offset %d\n",size,scanner_p->size*CellSize,result_offset ));
return ( result_offset );
}
-BOOL shm_free(shm_offset_t offset)
+BOOL smb_shm_free(smb_shm_offset_t offset)
{
- struct ShmBlockDesc *header_p ; /* pointer to header of block to free */
- struct ShmBlockDesc *scanner_p ; /* used to scan the list */
- struct ShmBlockDesc *prev_p ; /* holds previous in the list */
+ struct SmbShmBlockDesc *header_p ; /* pointer to header of block to free */
+ struct SmbShmBlockDesc *scanner_p ; /* used to scan the list */
+ struct SmbShmBlockDesc *prev_p ; /* holds previous in the list */
- if( !shm_header_p )
+ if( !smb_shm_header_p )
{
/* not mapped yet */
- DEBUG(0,("ERROR shm_free : shmem not mapped\n"));
+ DEBUG(0,("ERROR smb_shm_free : shmem not mapped\n"));
return False;
}
- if( !shm_header_p->consistent)
+ if( !smb_shm_header_p->consistent)
{
- DEBUG(0,("ERROR shm_free : shmem not consistent\n"));
+ DEBUG(0,("ERROR smb_shm_free : shmem not consistent\n"));
return False;
}
- header_p = ( (struct ShmBlockDesc *)shm_offset2addr(offset) - 1); /* make pointer to header of block */
+ header_p = ( (struct SmbShmBlockDesc *)smb_shm_offset2addr(offset) - 1); /* make pointer to header of block */
- if (header_p->next != SHM_NOT_FREE_OFF)
+ if (header_p->next != SMB_SHM_NOT_FREE_OFF)
{
- DEBUG(0,("ERROR shm_free : bad offset (%d)\n",offset));
+ DEBUG(0,("ERROR smb_shm_free : bad offset (%d)\n",offset));
return False;
}
/* find a place in the free_list to put the header in */
/* set scanner and previous pointer to start of list */
- prev_p = (struct ShmBlockDesc *)shm_offset2addr(shm_header_p->first_free_off);
+ prev_p = (struct SmbShmBlockDesc *)smb_shm_offset2addr(smb_shm_header_p->first_free_off);
scanner_p = prev_p ;
while ( ( scanner_p != EOList_Addr) && (scanner_p < header_p) ) /* while we didn't scan past its position */
{
prev_p = scanner_p ;
- scanner_p = (struct ShmBlockDesc *)shm_offset2addr(scanner_p->next);
+ scanner_p = (struct SmbShmBlockDesc *)smb_shm_offset2addr(scanner_p->next);
}
- shm_header_p->consistent = False;
+ smb_shm_header_p->consistent = False;
- DEBUG(2,("shm_free : freeing %d bytes at offset %d\n",header_p->size*CellSize,offset));
+ DEBUG(2,("smb_shm_free : freeing %d bytes at offset %d\n",header_p->size*CellSize,offset));
if ( scanner_p == prev_p )
{
- shm_header_p->statistics.cells_free += header_p->size;
- shm_header_p->statistics.cells_used -= header_p->size;
+ smb_shm_header_p->statistics.cells_free += header_p->size;
+ smb_shm_header_p->statistics.cells_used -= header_p->size;
/* we must free it at the beginning of the list */
- shm_header_p->first_free_off = shm_addr2offset(header_p); /* set the free_list_pointer to this block_header */
+ smb_shm_header_p->first_free_off = smb_shm_addr2offset(header_p); /* set the free_list_pointer to this block_header */
/* scanner is the one that was first in the list */
- header_p->next = shm_addr2offset(scanner_p);
- shm_solve_neighbors( header_p ); /* if neighbors then link them */
+ header_p->next = smb_shm_addr2offset(scanner_p);
+ smb_shm_solve_neighbors( header_p ); /* if neighbors then link them */
- shm_header_p->consistent = True;
+ smb_shm_header_p->consistent = True;
return True;
}
else
{
- shm_header_p->statistics.cells_free += header_p->size;
- shm_header_p->statistics.cells_used -= header_p->size;
+ smb_shm_header_p->statistics.cells_free += header_p->size;
+ smb_shm_header_p->statistics.cells_used -= header_p->size;
- prev_p->next = shm_addr2offset(header_p);
- header_p->next = shm_addr2offset(scanner_p);
- shm_solve_neighbors(header_p) ;
- shm_solve_neighbors(prev_p) ;
+ prev_p->next = smb_shm_addr2offset(header_p);
+ header_p->next = smb_shm_addr2offset(scanner_p);
+ smb_shm_solve_neighbors(header_p) ;
+ smb_shm_solve_neighbors(prev_p) ;
- shm_header_p->consistent = True;
+ smb_shm_header_p->consistent = True;
return True;
}
}
-shm_offset_t shm_get_userdef_off(void)
+smb_shm_offset_t smb_shm_get_userdef_off(void)
{
- if (!shm_header_p)
+ if (!smb_shm_header_p)
return NULL_OFFSET;
else
- return shm_header_p->userdef_off;
+ return smb_shm_header_p->userdef_off;
}
-BOOL shm_set_userdef_off(shm_offset_t userdef_off)
+BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off)
{
- if (!shm_header_p)
+ if (!smb_shm_header_p)
return False;
else
- shm_header_p->userdef_off = userdef_off;
+ smb_shm_header_p->userdef_off = userdef_off;
return True;
}
-void * shm_offset2addr(shm_offset_t offset)
+void * smb_shm_offset2addr(smb_shm_offset_t offset)
{
if (offset == NULL_OFFSET )
return (void *)(0);
- if (!shm_header_p)
+ if (!smb_shm_header_p)
return (void *)(0);
- return (void *)((char *)shm_header_p + offset );
+ return (void *)((char *)smb_shm_header_p + offset );
}
-shm_offset_t shm_addr2offset(void *addr)
+smb_shm_offset_t smb_shm_addr2offset(void *addr)
{
if (!addr)
return NULL_OFFSET;
- if (!shm_header_p)
+ if (!smb_shm_header_p)
return NULL_OFFSET;
- return (shm_offset_t)((char *)addr - (char *)shm_header_p);
+ return (smb_shm_offset_t)((char *)addr - (char *)smb_shm_header_p);
}
-BOOL shm_lock(void)
+BOOL smb_shm_lock(void)
{
- if (shm_fd < 0)
+ if (smb_shm_fd < 0)
{
- DEBUG(0,("ERROR shm_lock : bad shm_fd (%d)\n",shm_fd));
+ DEBUG(0,("ERROR smb_shm_lock : bad smb_shm_fd (%d)\n",smb_shm_fd));
return False;
}
- shm_times_locked++;
+ smb_shm_times_locked++;
- if(shm_times_locked > 1)
+ if(smb_shm_times_locked > 1)
{
- DEBUG(2,("shm_lock : locked %d times\n",shm_times_locked));
+ DEBUG(2,("smb_shm_lock : locked %d times\n",smb_shm_times_locked));
return True;
}
- if (lockf(shm_fd, F_LOCK, 0) < 0)
+ if (lockf(smb_shm_fd, F_LOCK, 0) < 0)
{
- DEBUG(0,("ERROR shm_lock : lockf failed with code %d\n",errno));
- shm_times_locked--;
+ DEBUG(0,("ERROR smb_shm_lock : lockf failed with code %d\n",errno));
+ smb_shm_times_locked--;
return False;
}
@@ -662,32 +662,32 @@ BOOL shm_lock(void)
-BOOL shm_unlock(void)
+BOOL smb_shm_unlock(void)
{
- if (shm_fd < 0)
+ if (smb_shm_fd < 0)
{
- DEBUG(0,("ERROR shm_unlock : bad shm_fd (%d)\n",shm_fd));
+ DEBUG(0,("ERROR smb_shm_unlock : bad smb_shm_fd (%d)\n",smb_shm_fd));
return False;
}
- if(shm_times_locked == 0)
+ if(smb_shm_times_locked == 0)
{
- DEBUG(0,("ERROR shm_unlock : shmem not locked\n",shm_fd));
+ DEBUG(0,("ERROR smb_shm_unlock : shmem not locked\n",smb_shm_fd));
return False;
}
- shm_times_locked--;
+ smb_shm_times_locked--;
- if(shm_times_locked > 0)
+ if(smb_shm_times_locked > 0)
{
- DEBUG(2,("shm_unlock : still locked %d times\n",shm_times_locked));
+ DEBUG(2,("smb_shm_unlock : still locked %d times\n",smb_shm_times_locked));
return True;
}
- if (lockf(shm_fd, F_ULOCK, 0) < 0)
+ if (lockf(smb_shm_fd, F_ULOCK, 0) < 0)
{
- DEBUG(0,("ERROR shm_unlock : lockf failed with code %d\n",errno));
- shm_times_locked++;
+ DEBUG(0,("ERROR smb_shm_unlock : lockf failed with code %d\n",errno));
+ smb_shm_times_locked++;
return False;
}
@@ -696,19 +696,19 @@ BOOL shm_unlock(void)
}
-BOOL shm_get_usage(int *bytes_free,
+BOOL smb_shm_get_usage(int *bytes_free,
int *bytes_used,
int *bytes_overhead)
{
- if( !shm_header_p )
+ if( !smb_shm_header_p )
{
/* not mapped yet */
- DEBUG(0,("ERROR shm_free : shmem not mapped\n"));
+ DEBUG(0,("ERROR smb_shm_free : shmem not mapped\n"));
return False;
}
- *bytes_free = shm_header_p->statistics.cells_free * CellSize;
- *bytes_used = shm_header_p->statistics.cells_used * CellSize;
- *bytes_overhead = shm_header_p->statistics.cells_system * CellSize + AlignedHeaderSize;
+ *bytes_free = smb_shm_header_p->statistics.cells_free * CellSize;
+ *bytes_used = smb_shm_header_p->statistics.cells_used * CellSize;
+ *bytes_overhead = smb_shm_header_p->statistics.cells_system * CellSize + AlignedHeaderSize;
return True;
}
diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c
index 3e22e26ba3..aec349dfd1 100644
--- a/source3/smbd/quotas.c
+++ b/source3/smbd/quotas.c
@@ -413,7 +413,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
r= quotactl(path,Q_GETQUOTA,euser_id,(char *) &D);
#else
r=quotactl(Q_GETQUOTA, dev_disk, euser_id, &D);
- #endif
+#endif
#endif
/* Use softlimit to determine disk space, except when it has been exceeded */
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 69fbda5ea8..459349f5eb 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -175,27 +175,27 @@ unsigned int Ucrit_IsActive = 0; /* added by OH */
trim_string(shmem_file_name,"","/");
if (!*shmem_file_name) exit(-1);
strcat(shmem_file_name, "/SHARE_MEM_FILE");
- if(!shm_open(shmem_file_name, SHMEM_SIZE)) exit(-1);
+ if(!smb_shm_open(shmem_file_name, SHMEM_SIZE)) exit(-1);
- if(!shm_lock())
+ if(!smb_shm_lock())
{
- shm_close();
+ smb_shm_close();
exit (-1);
}
- scanner_p = (share_mode_record *)shm_offset2addr(shm_get_userdef_off());
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(smb_shm_get_userdef_off());
prev_p = scanner_p;
while(scanner_p)
{
int pid,mode;
- time_t t;
+ struct timeval t;
pid = scanner_p->pid;
if ( !Ucrit_checkPid(pid) )
{
prev_p = scanner_p ;
- scanner_p = (share_mode_record *)shm_offset2addr(scanner_p->next_offset);
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(scanner_p->next_offset);
continue;
}
@@ -204,20 +204,21 @@ unsigned int Ucrit_IsActive = 0; /* added by OH */
DEBUG(2,("Deleting stale share mode record"));
if(prev_p == scanner_p)
{
- shm_set_userdef_off(scanner_p->next_offset);
- shm_free(shm_addr2offset(scanner_p));
- scanner_p = (share_mode_record *)shm_offset2addr(shm_get_userdef_off());
+ smb_shm_set_userdef_off(scanner_p->next_offset);
+ smb_shm_free(smb_shm_addr2offset(scanner_p));
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(smb_shm_get_userdef_off());
prev_p = scanner_p;
}
else
{
prev_p->next_offset = scanner_p->next_offset;
- shm_free(shm_addr2offset(scanner_p));
- scanner_p = (share_mode_record *)shm_offset2addr(prev_p->next_offset);
+ smb_shm_free(smb_shm_addr2offset(scanner_p));
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(prev_p->next_offset);
}
continue;
}
- t = scanner_p->time;
+ t.tv_sec = scanner_p->time.tv_sec;
+ t.tv_usec = scanner_p->time.tv_usec;
mode = scanner_p->share_mode;
strcpy(fname, scanner_p->file_name);
#else
@@ -289,17 +290,17 @@ unsigned int Ucrit_IsActive = 0; /* added by OH */
#if FAST_SHARE_MODES
prev_p = scanner_p ;
- scanner_p = (share_mode_record *)shm_offset2addr(scanner_p->next_offset);
+ scanner_p = (share_mode_record *)smb_shm_offset2addr(scanner_p->next_offset);
} /* end while */
- shm_get_usage(&bytes_free, &bytes_used, &bytes_overhead);
+ smb_shm_get_usage(&bytes_free, &bytes_used, &bytes_overhead);
bytes_total = bytes_free + bytes_used + bytes_overhead;
- shm_unlock();
+ smb_shm_unlock();
/*******************************************************************
deinitialize the shared memory for share_mode management
******************************************************************/
- shm_close();
+ smb_shm_close();
#else
} /* end while */