mc/vfs/samba/tests/fcntl_lock.c
Miguel de Icaza 2a8730b21c 1999-06-01 Robert Brady <rwb197@ecs.soton.ac.uk>
* file.c (move_dir_dir): Give an error when an attempt is made to
	move an empty directory into itself.

1999-06-14  Wayne Roberts <wroberts1@cx983858-b.orng1.occa.home.com>

	* vfs/smbfs.c: New file.  Implements the Samba-based file system.

	* vfs/vfs.h: Declare vfs_smbfs_ops, vfs_file_is_smb.

	* vfs/vfs.c (vfs_file_is_smb): implemented.
	(vfs_init) register smbfs.

	* vfs/samba: Incorporate SAMBA source code required for smbfs

1999-05-27  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* Make.common.in (confdir): Define confdir as sysconfdir.  This
	should fix the problem we had with FSSTND distributions.
1999-06-22 19:56:36 +00:00

84 lines
1.4 KiB
C

/* test whether fcntl locking works on this system */
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
#include <errno.h>
static int sys_waitpid(pid_t pid,int *status,int options)
{
#ifdef HAVE_WAITPID
return waitpid(pid,status,options);
#else /* USE_WAITPID */
return wait4(pid, status, options, NULL);
#endif /* USE_WAITPID */
}
#define DATA "conftest.fcntl"
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
/* lock a byte range in a open file */
int main(int argc, char *argv[])
{
struct flock lock;
int fd, pid, ret, status=1;
if (!(pid=fork())) {
sleep(2);
fd = open(DATA, O_RDONLY);
if (fd == -1) exit(1);
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 4;
lock.l_pid = getpid();
lock.l_type = F_WRLCK;
/* check if a lock applies */
ret = fcntl(fd,F_GETLK,&lock);
if ((ret == -1) ||
(lock.l_type == F_UNLCK)) {
exit(1);
} else {
exit(0);
}
}
fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600);
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 4;
lock.l_pid = getpid();
/* set a 4 byte write lock */
fcntl(fd,F_SETLK,&lock);
sys_waitpid(pid, &status, 0);
unlink(DATA);
exit(status);
}