From 8bc7d6bebd4fcf8c95cb6d58da14404a5e46de91 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Thu, 9 Jan 1997 18:02:17 +0000 Subject: Makefile: Changes to split Solaris into Solaris2.3 and previous, and 2.4 and after from Paul Eggert. Makefile: Added AMIGA changes from Rask Ingemann Lambertsen . charset.c: Patch for Western European Languages from Josef Hinteregger charset.h: Patch for Western European Languages from Josef Hinteregger clitar.c: Patch to re-sync after read fail from (lost contributor name, sorry). includes.h: Patch for AMIGA from Rask Ingemann Lambertsen includes.h: Patch for SunOS atexit by Jeremy (jra@cygnus.com) interface.c: Patch for AMIGA from Rask Ingemann Lambertsen kanji.h: Patch for Western European Languages from Josef Hinteregger locking.c: Patch to fix file locking from Jeremy (jra@cygnus.com) locking.c: Patch to add granularity of lock files to usec by Jeremy (jra@cygnus.com) pipes.c: Patch to fix file locking from Jeremy (jra@cygnus.com) proto.h: Patch to fix file locking from Jeremy (jra@cygnus.com) reply.c: Patch to fix file locking from Jeremy (jra@cygnus.com) server.c: Patch to fix file locking from Jeremy (jra@cygnus.com) server.c: Patch for FAST_SHARE_MODE fix from (lost contributor name, sorry). smb.h: Patch to fix file locking from Jeremy (jra@cygnus.com) smb.h: Patch to add granularity of lock files to usec by Jeremy (jra@cygnus.com) status.c: Patch to fix file locking from Jeremy (jra@cygnus.com) statuc.c: Patch to add granularity of lock files to usec by Jeremy (jra@cygnus.com) system.c: Patch for Western European Languages from Josef Hinteregger trans2.c: Patch to fix file locking from Jeremy (jra@cygnus.com) trans2.c: Patch to fix volume name reported to Win95 from Jeremy (jra@cygnus.com) util.c: Patch for Western European Languages from Josef Hinteregger util.c: Patch to fix client_name from continuously returning UNKNOWN (from various contributors). version.h: Update to 1.9.16p10. (This used to be commit 03d28fa32eb094affa33133ebe2602fdb70f6361) --- source3/locking/locking.c | 64 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 29 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index dde9477e23..d94cc9c35f 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -45,7 +45,7 @@ BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset) if (!lp_locking(snum) || !lp_strict_locking(snum)) return(False); - return(fcntl_lock(Files[fnum].fd,F_GETLK,offset,count, + return(fcntl_lock(Files[fnum].fd_ptr->fd,F_GETLK,offset,count, (Files[fnum].can_write?F_WRLCK:F_RDLCK))); } @@ -67,7 +67,7 @@ BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ec } if (Files[fnum].can_lock && OPEN_FNUM(fnum) && (Files[fnum].cnum == cnum)) - ok = fcntl_lock(Files[fnum].fd,F_SETLK,offset,count, + ok = fcntl_lock(Files[fnum].fd_ptr->fd,F_SETLK,offset,count, (Files[fnum].can_write?F_WRLCK:F_RDLCK)); if (!ok) { @@ -90,7 +90,7 @@ BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 * return(True); if (Files[fnum].can_lock && OPEN_FNUM(fnum) && (Files[fnum].cnum == cnum)) - ok = fcntl_lock(Files[fnum].fd,F_SETLK,offset,count,F_UNLCK); + ok = fcntl_lock(Files[fnum].fd_ptr->fd,F_SETLK,offset,count,F_UNLCK); if (!ok) { *eclass = ERRDOS; @@ -151,7 +151,7 @@ static BOOL share_name(int cnum,struct stat *st,char *name) static BOOL share_name_fnum(int fnum,char *name) { struct stat st; - if (fstat(Files[fnum].fd,&st) != 0) return(False); + if (fstat(Files[fnum].fd_ptr->fd,&st) != 0) return(False); return(share_name(Files[fnum].cnum,&st,name)); } @@ -163,7 +163,7 @@ static BOOL share_name_fnum(int fnum,char *name) int get_share_mode_by_fnum(int cnum,int fnum,int *pid) { struct stat sbuf; - if (fstat(Files[fnum].fd,&sbuf) == -1) return(0); + if (fstat(Files[fnum].fd_ptr->fd,&sbuf) == -1) return(0); return(get_share_mode(cnum,&sbuf,pid)); } @@ -257,9 +257,9 @@ int get_share_mode(int cnum,struct stat *sbuf,int *pid) #else pstring fname; int fd2; - char buf[16]; + char buf[20]; int ret; - time_t t; + struct timeval t; *pid = 0; @@ -268,18 +268,20 @@ int get_share_mode(int cnum,struct stat *sbuf,int *pid) fd2 = open(fname,O_RDONLY,0); if (fd2 < 0) return(0); - if (read(fd2,buf,16) != 16) { + if (read(fd2,buf,20) != 20) { + DEBUG(2,("Failed to read share file %s\n",fname)); close(fd2); unlink(fname); return(0); } close(fd2); - t = IVAL(buf,0); - ret = IVAL(buf,4); - *pid = IVAL(buf,8); + t.tv_sec = IVAL(buf,4); + t.tv_usec = IVAL(buf,8); + ret = IVAL(buf,12); + *pid = IVAL(buf,16); - if (IVAL(buf,12) != LOCKING_VERSION) { + if (IVAL(buf,0) != LOCKING_VERSION) { if (!unlink(fname)) DEBUG(2,("Deleted old locking file %s",fname)); *pid = 0; return(0); @@ -368,29 +370,31 @@ void del_share_mode(int fnum) #else pstring fname; int fd2; - char buf[16]; - time_t t=0; + char buf[20]; + struct timeval t; int pid=0; BOOL del = False; + t.tv_sec = t.tv_usec = 0; if (!share_name_fnum(fnum,fname)) return; fd2 = open(fname,O_RDONLY,0); if (fd2 < 0) return; - if (read(fd2,buf,16) != 16) + if (read(fd2,buf,20) != 20) del = True; close(fd2); if (!del) { - t = IVAL(buf,0); - pid = IVAL(buf,8); + t.tv_sec = IVAL(buf,4); + t.tv_usec = IVAL(buf,8); + pid = IVAL(buf,16); } if (!del) - if (IVAL(buf,12) != LOCKING_VERSION || !pid || !process_exists(pid)) + if (IVAL(buf,0) != 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) { @@ -443,7 +447,7 @@ BOOL set_share_mode(int fnum,int mode) #else pstring fname; int fd2; - char buf[16]; + char buf[20]; int pid = (int)getpid(); if (!share_name_fnum(fnum,fname)) return(False); @@ -458,12 +462,14 @@ BOOL set_share_mode(int fnum,int mode) return(False); } - SIVAL(buf,0,Files[fnum].open_time); - SIVAL(buf,4,mode); - SIVAL(buf,8,pid); - SIVAL(buf,12,LOCKING_VERSION); + SIVAL(buf,0,LOCKING_VERSION); + SIVAL(buf,4,Files[fnum].open_time.tv_sec); + SIVAL(buf,8,Files[fnum].open_time.tv_usec); + SIVAL(buf,12,mode); + SIVAL(buf,16,pid); - if (write(fd2,buf,16) != 16) { + if (write(fd2,buf,20) != 20) { + DEBUG(2,("Failed to write share file %s\n",fname)); close(fd2); unlink(fname); return(False); @@ -538,7 +544,7 @@ void clean_share_modes(void) if (!dir) return; while ((s=readdirname(dir))) { - char buf[16]; + char buf[20]; int pid; int fd; pstring lname; @@ -554,7 +560,7 @@ void clean_share_modes(void) fd = open(lname,O_RDONLY,0); if (fd < 0) continue; - if (read(fd,buf,16) != 16) { + if (read(fd,buf,20) != 20) { close(fd); if (!unlink(lname)) printf("Deleted corrupt share file %s\n",s); @@ -562,9 +568,9 @@ void clean_share_modes(void) } close(fd); - pid = IVAL(buf,8); + pid = IVAL(buf,16); - if (IVAL(buf,12) != LOCKING_VERSION || !process_exists(pid)) { + if (IVAL(buf,0) != LOCKING_VERSION || !process_exists(pid)) { if (!unlink(lname)) printf("Deleted stale share file %s\n",s); } -- cgit