2 Unix SMB/Netbios implementation.
4 slow (lockfile) locking implementation
5 Copyright (C) Andrew Tridgell 1992-1998
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 12 aug 96: Erik.Devriendt@te6.siemens.be
24 added support for shared memory implementation of share mode locking
26 May 1997. Jeremy Allison (jallison@whistle.com). Modified share mode
27 locking to deal with multiple share modes per open file.
29 September 1997. Jeremy Allison (jallison@whistle.com). Added oplock
32 October 1997 - split into separate file (tridge)
37 #ifndef FAST_SHARE_MODES
39 extern int DEBUGLEVEL;
40 extern connection_struct Connections[];
41 extern files_struct Files[];
44 * Locking file header lengths & offsets.
46 #define SMF_VERSION_OFFSET 0
47 #define SMF_NUM_ENTRIES_OFFSET 4
48 #define SMF_FILENAME_LEN_OFFSET 8
49 #define SMF_HEADER_LENGTH 10
51 #define SMF_ENTRY_LENGTH 20
54 * Share mode record offsets.
57 #define SME_SEC_OFFSET 0
58 #define SME_USEC_OFFSET 4
59 #define SME_SHAREMODE_OFFSET 8
60 #define SME_PID_OFFSET 12
61 #define SME_PORT_OFFSET 16
62 #define SME_OPLOCK_TYPE_OFFSET 18
64 /* we need world read for smbstatus to function correctly */
65 #ifdef SECURE_SHARE_MODES
66 #define SHARE_FILE_MODE 0600
68 #define SHARE_FILE_MODE 0644
73 /*******************************************************************
74 deinitialize share_mode management
75 ******************************************************************/
76 static BOOL slow_stop_share_mode_mgmt(void)
82 /*******************************************************************
84 ******************************************************************/
85 static BOOL share_name(int cnum, uint32 dev, uint32 inode, char *name)
88 pstrcpy(name,lp_lockdir());
89 trim_string(name,"","/");
90 if (!*name) return(False);
94 slprintf(name, sizeof(pstring) - len - 1, "/share.%u.%u",dev,inode);
98 /*******************************************************************
99 Force a share file to be deleted.
100 ********************************************************************/
101 static int delete_share_file( int cnum, char *fname )
103 if (read_only) return -1;
105 /* the share file could be owned by anyone, so do this as root */
108 if(unlink(fname) != 0)
110 DEBUG(0,("delete_share_file: Can't delete share file %s (%s)\n",
111 fname, strerror(errno)));
115 DEBUG(5,("delete_share_file: Deleted share file %s\n", fname));
118 /* return to our previous privilage level */
119 unbecome_root(False);
124 /*******************************************************************
125 lock a share mode file.
126 ******************************************************************/
127 static BOOL slow_lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
135 if(!share_name(cnum, dev, inode, fname))
138 if (read_only) return True;
140 /* we need to do this as root */
144 BOOL gotlock = False;
146 * There was a race condition in the original slow share mode code.
147 * A smbd could open a share mode file, and before getting
148 * the lock, another smbd could delete the last entry for
149 * the share mode file and delete the file entry from the
150 * directory. Thus this smbd would be left with a locked
151 * share mode fd attached to a file that no longer had a
152 * directory entry. Thus another smbd would think that
153 * there were no outstanding opens on the file. To fix
154 * this we now check we can do a stat() call on the filename
155 * before allowing the lock to proceed, and back out completely
156 * and try the open again if we cannot.
157 * Jeremy Allison (jallison@whistle.com).
162 struct stat dummy_stat;
164 fd = (int)open(fname,read_only?O_RDONLY:(O_RDWR|O_CREAT),
169 DEBUG(0,("ERROR lock_share_entry: failed to open share file %s. Error was %s\n",
170 fname, strerror(errno)));
175 /* At this point we have an open fd to the share mode file.
176 Lock the first byte exclusively to signify a lock. */
177 if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False)
179 DEBUG(0,("ERROR lock_share_entry: fcntl_lock on file %s failed with %s\n",
180 fname, strerror(errno)));
187 * If we cannot stat the filename, the file was deleted between
188 * the open and the lock call. Back out and try again.
191 if(stat(fname, &dummy_stat)!=0)
193 DEBUG(2,("lock_share_entry: Re-issuing open on %s to fix race. Error was %s\n",
194 fname, strerror(errno)));
202 * We have to come here if any of the above calls fail
203 * as we don't want to return and leave ourselves running
210 /* return to our previous privilage level */
211 unbecome_root(False);
216 /*******************************************************************
217 unlock a share mode file.
218 ******************************************************************/
219 static BOOL slow_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token)
226 if (read_only) return True;
228 /* Fix for zero length share files from
229 Gerald Werner <wernerg@mfldclin.edu> */
231 share_name(cnum, dev, inode, fname);
233 /* get the share mode file size */
234 if(fstat((int)token, &sb) != 0)
236 DEBUG(0,("ERROR: unlock_share_entry: Failed to do stat on share file %s (%s)\n",
237 fname, strerror(errno)));
242 /* If the file was zero length, we must delete before
243 doing the unlock to avoid a race condition (see
244 the code in lock_share_mode_entry for details.
247 /* remove the share file if zero length */
249 delete_share_file(cnum, fname);
251 /* token is the fd of the open share mode file. */
252 /* Unlock the first byte. */
253 if(fcntl_lock(fd, F_SETLKW, 0, 1, F_UNLCK) == False)
255 DEBUG(0,("ERROR unlock_share_entry: fcntl_lock failed with %s\n",
264 /*******************************************************************
265 Read a share file into a buffer.
266 ********************************************************************/
267 static int read_share_file(int cnum, int fd, char *fname, char **out, BOOL *p_new_file)
276 if(fstat(fd, &sb) != 0)
278 DEBUG(0,("ERROR: read_share_file: Failed to do stat on share file %s (%s)\n",
279 fname, strerror(errno)));
289 /* Allocate space for the file */
290 if((buf = (char *)malloc(sb.st_size)) == NULL)
292 DEBUG(0,("read_share_file: malloc for file size %d fail !\n", sb.st_size));
296 if(lseek(fd, 0, SEEK_SET) != 0)
298 DEBUG(0,("ERROR: read_share_file: Failed to reset position to 0 \
299 for share file %s (%s)\n", fname, strerror(errno)));
305 if (read(fd,buf,sb.st_size) != sb.st_size)
307 DEBUG(0,("ERROR: read_share_file: Failed to read share file %s (%s)\n",
308 fname, strerror(errno)));
314 if (IVAL(buf,SMF_VERSION_OFFSET) != LOCKING_VERSION) {
315 DEBUG(0,("ERROR: read_share_file: share file %s has incorrect \
316 locking version (was %d, should be %d).\n",fname,
317 IVAL(buf,SMF_VERSION_OFFSET), LOCKING_VERSION));
320 delete_share_file(cnum, fname);
324 /* Sanity check for file contents */
326 size -= SMF_HEADER_LENGTH; /* Remove the header */
328 /* Remove the filename component. */
329 size -= SVAL(buf, SMF_FILENAME_LEN_OFFSET);
331 /* The remaining size must be a multiple of SMF_ENTRY_LENGTH - error if not. */
332 if((size % SMF_ENTRY_LENGTH) != 0)
334 DEBUG(0,("ERROR: read_share_file: share file %s is an incorrect length - \
335 deleting it.\n", fname));
338 delete_share_file(cnum, fname);
346 /*******************************************************************
347 get all share mode entries in a share file for a dev/inode pair.
348 ********************************************************************/
349 static int slow_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
350 share_mode_entry **old_shares)
356 int num_entries_copied;
358 share_mode_entry *share_array;
365 /* Read the share file header - this is of the form:
367 4 - number of share mode entries.
368 8 - 2 byte name length
369 [n bytes] file name (zero terminated).
371 Followed by <n> share mode entries of the form :
377 16 - oplock port (if oplocks in use) - 2 bytes.
380 share_name(cnum, dev, inode, fname);
382 if(read_share_file( cnum, fd, fname, &buf, &new_file) != 0)
384 DEBUG(0,("ERROR: get_share_modes: Failed to read share file %s\n",
392 num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
394 DEBUG(5,("get_share_modes: share file %s has %d share mode entries.\n",
395 fname, num_entries));
400 DEBUG(0,("PANIC ERROR:get_share_mode: num_share_mode_entries < 0 (%d) \
401 for share file %d\n", num_entries, fname));
407 *old_shares = share_array = (share_mode_entry *)
408 malloc(num_entries * sizeof(share_mode_entry));
411 DEBUG(0,("get_share_modes: malloc fail !\n"));
417 /* No entries - just delete the file. */
418 DEBUG(0,("get_share_modes: share file %s has no share mode entries - deleting.\n",
422 delete_share_file(cnum, fname);
426 num_entries_copied = 0;
427 base = buf + SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
429 for( i = 0; i < num_entries; i++)
432 char *p = base + (i*SMF_ENTRY_LENGTH);
434 pid = IVAL(p,SME_PID_OFFSET);
436 if(!process_exists(pid))
438 DEBUG(0,("get_share_modes: process %d no longer exists and \
439 it left a share mode entry with mode 0x%X in share file %s\n",
440 pid, IVAL(p,SME_SHAREMODE_OFFSET), fname));
443 share_array[num_entries_copied].time.tv_sec = IVAL(p,SME_SEC_OFFSET);
444 share_array[num_entries_copied].time.tv_usec = IVAL(p,SME_USEC_OFFSET);
445 share_array[num_entries_copied].share_mode = IVAL(p,SME_SHAREMODE_OFFSET);
446 share_array[num_entries_copied].pid = pid;
447 share_array[num_entries_copied].op_port = SVAL(p,SME_PORT_OFFSET);
448 share_array[num_entries_copied].op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
450 num_entries_copied++;
453 if(num_entries_copied == 0)
455 /* Delete the whole file. */
456 DEBUG(0,("get_share_modes: share file %s had no valid entries - deleting it !\n",
459 free((char *)*old_shares);
463 delete_share_file(cnum, fname);
467 /* If we deleted some entries we need to re-write the whole number of
468 share mode entries back into the file. */
470 if(num_entries_copied != num_entries)
472 if(lseek(fd, 0, SEEK_SET) != 0)
474 DEBUG(0,("ERROR: get_share_modes: lseek failed to reset to \
475 position 0 for share mode file %s (%s)\n", fname, strerror(errno)));
477 free((char *)*old_shares);
484 SIVAL(buf, SMF_NUM_ENTRIES_OFFSET, num_entries_copied);
485 for( i = 0; i < num_entries_copied; i++)
487 char *p = base + (i*SMF_ENTRY_LENGTH);
489 SIVAL(p,SME_PID_OFFSET,share_array[i].pid);
490 SIVAL(p,SME_SHAREMODE_OFFSET,share_array[i].share_mode);
491 SIVAL(p,SME_SEC_OFFSET,share_array[i].time.tv_sec);
492 SIVAL(p,SME_USEC_OFFSET,share_array[i].time.tv_usec);
493 SSVAL(p,SME_PORT_OFFSET,share_array[i].op_port);
494 SSVAL(p,SME_OPLOCK_TYPE_OFFSET,share_array[i].op_type);
497 newsize = (base - buf) + (SMF_ENTRY_LENGTH*num_entries_copied);
498 if(write(fd, buf, newsize) != newsize)
500 DEBUG(0,("ERROR: get_share_modes: failed to re-write share \
501 mode file %s (%s)\n", fname, strerror(errno)));
503 free((char *)*old_shares);
509 /* Now truncate the file at this point. */
510 if(ftruncate(fd, newsize)!= 0)
512 DEBUG(0,("ERROR: get_share_modes: failed to ftruncate share \
513 mode file %s to size %d (%s)\n", fname, newsize, strerror(errno)));
515 free((char *)*old_shares);
526 DEBUG(5,("get_share_modes: Read share file %s returning %d entries\n",fname,
527 num_entries_copied));
529 return num_entries_copied;
532 /*******************************************************************
533 del a share mode from a share mode file.
534 ********************************************************************/
535 static void slow_del_share_mode(int token, int fnum)
544 files_struct *fs_p = &Files[fnum];
546 BOOL deleted = False;
549 share_name(fs_p->cnum, fs_p->fd_ptr->dev,
550 fs_p->fd_ptr->inode, fname);
552 if(read_share_file( fs_p->cnum, fd, fname, &buf, &new_file) != 0)
554 DEBUG(0,("ERROR: del_share_mode: Failed to read share file %s\n",
561 DEBUG(0,("ERROR:del_share_mode: share file %s is new (size zero), deleting it.\n",
563 delete_share_file(fs_p->cnum, fname);
567 num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
569 DEBUG(5,("del_share_mode: share file %s has %d share mode entries.\n",
570 fname, num_entries));
575 DEBUG(0,("PANIC ERROR:del_share_mode: num_share_mode_entries < 0 (%d) \
576 for share file %d\n", num_entries, fname));
582 /* No entries - just delete the file. */
583 DEBUG(0,("del_share_mode: share file %s has no share mode entries - deleting.\n",
587 delete_share_file(fs_p->cnum, fname);
593 /* Go through the entries looking for the particular one
594 we have set - delete it.
597 base = buf + SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
599 for(i = 0; i < num_entries; i++)
601 char *p = base + (i*SMF_ENTRY_LENGTH);
603 if((IVAL(p,SME_SEC_OFFSET) != fs_p->open_time.tv_sec) ||
604 (IVAL(p,SME_USEC_OFFSET) != fs_p->open_time.tv_usec) ||
605 (IVAL(p,SME_SHAREMODE_OFFSET) != fs_p->share_mode) ||
606 (IVAL(p,SME_PID_OFFSET) != pid))
609 DEBUG(5,("del_share_mode: deleting entry number %d (of %d) from the share file %s\n",
610 i, num_entries, fname));
612 /* Remove this entry. */
613 if(i != num_entries - 1)
614 memcpy(p, p + SMF_ENTRY_LENGTH, (num_entries - i - 1)*SMF_ENTRY_LENGTH);
622 DEBUG(0,("del_share_mode: entry not found in share file %s\n", fname));
629 SIVAL(buf,SMF_NUM_ENTRIES_OFFSET, num_entries);
633 /* Deleted the last entry - remove the file. */
634 DEBUG(5,("del_share_mode: removed last entry in share file - deleting share file %s\n",
638 delete_share_file(fs_p->cnum,fname);
642 /* Re-write the file - and truncate it at the correct point. */
643 if(lseek(fd, 0, SEEK_SET) != 0)
645 DEBUG(0,("ERROR: del_share_mode: lseek failed to reset to \
646 position 0 for share mode file %s (%s)\n", fname, strerror(errno)));
652 newsize = (base - buf) + (SMF_ENTRY_LENGTH*num_entries);
653 if(write(fd, buf, newsize) != newsize)
655 DEBUG(0,("ERROR: del_share_mode: failed to re-write share \
656 mode file %s (%s)\n", fname, strerror(errno)));
662 /* Now truncate the file at this point. */
663 if(ftruncate(fd, newsize) != 0)
665 DEBUG(0,("ERROR: del_share_mode: failed to ftruncate share \
666 mode file %s to size %d (%s)\n", fname, newsize, strerror(errno)));
673 /*******************************************************************
674 set the share mode of a file
675 ********************************************************************/
676 static BOOL slow_set_share_mode(int token,int fnum, uint16 port, uint16 op_type)
678 files_struct *fs_p = &Files[fnum];
681 int pid = (int)getpid();
688 share_name(fs_p->cnum, fs_p->fd_ptr->dev,
689 fs_p->fd_ptr->inode, fname);
691 if(fstat(fd, &sb) != 0)
693 DEBUG(0,("ERROR: set_share_mode: Failed to do stat on share file %s\n",
698 /* Sanity check for file contents (if it's not a new share file). */
701 int size = sb.st_size;
703 /* Allocate space for the file plus one extra entry */
704 if((buf = (char *)malloc(sb.st_size + SMF_ENTRY_LENGTH)) == NULL)
706 DEBUG(0,("set_share_mode: malloc for file size %d fail !\n",
707 sb.st_size + SMF_ENTRY_LENGTH));
711 if(lseek(fd, 0, SEEK_SET) != 0)
713 DEBUG(0,("ERROR: set_share_mode: Failed to reset position \
714 to 0 for share file %s (%s)\n", fname, strerror(errno)));
720 if (read(fd,buf,sb.st_size) != sb.st_size)
722 DEBUG(0,("ERROR: set_share_mode: Failed to read share file %s (%s)\n",
723 fname, strerror(errno)));
729 if (IVAL(buf,SMF_VERSION_OFFSET) != LOCKING_VERSION)
731 DEBUG(0,("ERROR: set_share_mode: share file %s has incorrect \
732 locking version (was %d, should be %d).\n",fname, IVAL(buf,SMF_VERSION_OFFSET),
736 delete_share_file(fs_p->cnum, fname);
740 size -= (SMF_HEADER_LENGTH + SVAL(buf, SMF_FILENAME_LEN_OFFSET)); /* Remove the header */
742 /* The remaining size must be a multiple of SMF_ENTRY_LENGTH - error if not. */
743 if((size % SMF_ENTRY_LENGTH) != 0)
745 DEBUG(0,("ERROR: set_share_mode: share file %s is an incorrect length - \
746 deleting it.\n", fname));
749 delete_share_file(fs_p->cnum, fname);
756 /* New file - just use a single_entry. */
757 if((buf = (char *)malloc(SMF_HEADER_LENGTH +
758 strlen(fs_p->name) + 1 + SMF_ENTRY_LENGTH)) == NULL)
760 DEBUG(0,("ERROR: set_share_mode: malloc failed for single entry.\n"));
763 SIVAL(buf,SMF_VERSION_OFFSET,LOCKING_VERSION);
764 SIVAL(buf,SMF_NUM_ENTRIES_OFFSET,0);
765 SSVAL(buf,SMF_FILENAME_LEN_OFFSET,strlen(fs_p->name) + 1);
766 pstrcpy(buf + SMF_HEADER_LENGTH, fs_p->name);
769 num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
770 header_size = SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
771 p = buf + header_size + (num_entries * SMF_ENTRY_LENGTH);
772 SIVAL(p,SME_SEC_OFFSET,fs_p->open_time.tv_sec);
773 SIVAL(p,SME_USEC_OFFSET,fs_p->open_time.tv_usec);
774 SIVAL(p,SME_SHAREMODE_OFFSET,fs_p->share_mode);
775 SIVAL(p,SME_PID_OFFSET,pid);
776 SSVAL(p,SME_PORT_OFFSET,port);
777 SSVAL(p,SME_OPLOCK_TYPE_OFFSET,op_type);
781 SIVAL(buf,SMF_NUM_ENTRIES_OFFSET,num_entries);
783 if(lseek(fd, 0, SEEK_SET) != 0)
785 DEBUG(0,("ERROR: set_share_mode: (1) Failed to reset position to \
786 0 for share file %s (%s)\n", fname, strerror(errno)));
792 if (write(fd,buf,header_size + (num_entries*SMF_ENTRY_LENGTH)) !=
793 (header_size + (num_entries*SMF_ENTRY_LENGTH)))
795 DEBUG(2,("ERROR: set_share_mode: Failed to write share file %s - \
796 deleting it (%s).\n",fname, strerror(errno)));
797 delete_share_file(fs_p->cnum, fname);
803 /* Now truncate the file at this point - just for safety. */
805 if(ftruncate(fd, header_size + (SMF_ENTRY_LENGTH*num_entries))!= 0)
807 DEBUG(0,("ERROR: set_share_mode: failed to ftruncate share \
808 mode file %s to size %d (%s)\n", fname, header_size + (SMF_ENTRY_LENGTH*num_entries),
818 DEBUG(3,("set_share_mode: Created share file %s with \
819 mode 0x%X pid=%d\n",fname,fs_p->share_mode,pid));
824 /*******************************************************************
825 Remove an oplock port and mode entry from a share mode.
826 ********************************************************************/
827 static BOOL slow_remove_share_oplock(int fnum, int token)
836 files_struct *fs_p = &Files[fnum];
841 share_name(fs_p->cnum, fs_p->fd_ptr->dev,
842 fs_p->fd_ptr->inode, fname);
844 if(read_share_file( fs_p->cnum, fd, fname, &buf, &new_file) != 0)
846 DEBUG(0,("ERROR: remove_share_oplock: Failed to read share file %s\n",
853 DEBUG(0,("ERROR: remove_share_oplock: share file %s is new (size zero), \
854 deleting it.\n", fname));
855 delete_share_file(fs_p->cnum, fname);
859 num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
861 DEBUG(5,("remove_share_oplock: share file %s has %d share mode entries.\n",
862 fname, num_entries));
867 DEBUG(0,("PANIC ERROR:remove_share_oplock: num_share_mode_entries < 0 (%d) \
868 for share file %d\n", num_entries, fname));
874 /* No entries - just delete the file. */
875 DEBUG(0,("remove_share_oplock: share file %s has no share mode entries - deleting.\n",
879 delete_share_file(fs_p->cnum, fname);
885 /* Go through the entries looking for the particular one
886 we have set - remove the oplock settings on it.
889 base = buf + SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
891 for(i = 0; i < num_entries; i++)
893 char *p = base + (i*SMF_ENTRY_LENGTH);
895 if((IVAL(p,SME_SEC_OFFSET) != fs_p->open_time.tv_sec) ||
896 (IVAL(p,SME_USEC_OFFSET) != fs_p->open_time.tv_usec) ||
897 (IVAL(p,SME_SHAREMODE_OFFSET) != fs_p->share_mode) ||
898 (IVAL(p,SME_PID_OFFSET) != pid))
901 DEBUG(5,("remove_share_oplock: clearing oplock on entry number %d (of %d) \
902 from the share file %s\n", i, num_entries, fname));
904 SSVAL(p,SME_PORT_OFFSET,0);
905 SSVAL(p,SME_OPLOCK_TYPE_OFFSET,0);
912 DEBUG(0,("remove_share_oplock: entry not found in share file %s\n", fname));
918 /* Re-write the file - and truncate it at the correct point. */
919 if(lseek(fd, 0, SEEK_SET) != 0)
921 DEBUG(0,("ERROR: remove_share_oplock: lseek failed to reset to \
922 position 0 for share mode file %s (%s)\n", fname, strerror(errno)));
928 fsize = (base - buf) + (SMF_ENTRY_LENGTH*num_entries);
929 if(write(fd, buf, fsize) != fsize)
931 DEBUG(0,("ERROR: remove_share_oplock: failed to re-write share \
932 mode file %s (%s)\n", fname, strerror(errno)));
943 /*******************************************************************
944 call the specified function on each entry under management by the
946 ********************************************************************/
947 static int slow_share_forall(void (*fn)(share_mode_entry *, char *))
954 dir = opendir(lp_lockdir());
959 while ((s=readdirname(dir))) {
968 if (sscanf(s,"share.%u.%u",&dev,&inode)!=2) continue;
970 pstrcpy(lname,lp_lockdir());
971 trim_string(lname,NULL,"/");
975 fd = open(lname,read_only?O_RDONLY:O_RDWR,0);
980 /* Lock the share mode file while we read it. */
982 fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False) {
987 if(read_share_file( 0, fd, lname, &buf, &new_file)) {
991 pstrcpy( fname, &buf[10]);
994 base = buf + SMF_HEADER_LENGTH +
995 SVAL(buf,SMF_FILENAME_LEN_OFFSET);
996 for( i = 0; i < IVAL(buf, SMF_NUM_ENTRIES_OFFSET); i++) {
997 char *p = base + (i*SMF_ENTRY_LENGTH);
998 e.pid = IVAL(p,SME_PID_OFFSET);
999 e.share_mode = IVAL(p,SME_SHAREMODE_OFFSET);
1000 e.time.tv_sec = IVAL(p,SME_SEC_OFFSET);
1001 e.time.tv_usec = IVAL(p,SME_USEC_OFFSET);
1002 e.op_port = SVAL(p,SME_PORT_OFFSET);
1003 e.pid = SVAL(p,SME_PID_OFFSET);
1004 e.op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
1006 if (process_exists(e.pid)) {
1022 /*******************************************************************
1023 dump the state of the system
1024 ********************************************************************/
1025 static void slow_share_status(FILE *f)
1031 static struct share_ops share_ops = {
1032 slow_stop_share_mode_mgmt,
1033 slow_lock_share_entry,
1034 slow_unlock_share_entry,
1035 slow_get_share_modes,
1036 slow_del_share_mode,
1037 slow_set_share_mode,
1038 slow_remove_share_oplock,
1043 /*******************************************************************
1044 initialize the slow share_mode management
1045 ******************************************************************/
1046 struct share_ops *locking_slow_init(int ronly)
1051 if (!directory_exist(lp_lockdir(),NULL)) {
1053 mkdir(lp_lockdir(),0755);
1054 if (!directory_exist(lp_lockdir(),NULL))
1061 int locking_slow_dummy_procedure(void)
1063 #endif /* !FAST_SHARE_MODES */