Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jaak Ristioja
OpenLDAP
Commits
615923f0
Commit
615923f0
authored
26 years ago
by
Ben Collins
Browse files
Options
Downloads
Patches
Plain Diff
Functions for using fcntl to lock/unlock files in case lockf is not available
parent
27572b42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/lutil_lockf.h
+32
-0
32 additions, 0 deletions
include/lutil_lockf.h
libraries/liblutil/lockf.c
+41
-0
41 additions, 0 deletions
libraries/liblutil/lockf.c
with
73 additions
and
0 deletions
include/lutil_lockf.h
0 → 100644
+
32
−
0
View file @
615923f0
/*
* Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
*/
/* File locking methods */
#ifndef _LUTIL_LOCKF_H_
#define _LUTIL_LOCKF_H_
#include
<stdio.h>
#include
<ldap_cdefs.h>
#include
<ac/bytes.h>
#ifdef HAVE_FCNTL_H
#include
<fcntl.h>
#endif
#ifdef NEED_FCNTL_LOCKING
LDAP_BEGIN_DECL
LDAP_F
int
lutil_ldap_lockf
LDAP_P
((
FILE
*
fs
));
LDAP_F
int
lutil_ldap_unlockf
LDAP_P
((
FILE
*
fs
));
LDAP_END_DECL
#endif
/* NEED_FCNTL_LOCKING */
#endif
/* _LUTIL_LOCKF_H_ */
This diff is collapsed.
Click to expand it.
libraries/liblutil/lockf.c
0 → 100644
+
41
−
0
View file @
615923f0
/*
* Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
*/
/* File locking methods */
#include
"portable.h"
#include
<stdio.h>
#include
<ac/unistd.h>
#if defined(NEED_FCNTL_LOCKING) && defined(HAVE_FCNTL_H)
#include
<fcntl.h>
int
lutil_ldap_lockf
(
FILE
*
fs
)
{
struct
flock
file_lock
;
memset
(
&
file_lock
,
0
,
sizeof
(
file_lock
)
);
file_lock
.
l_type
=
F_WRLCK
;
file_lock
.
l_whence
=
SEEK_SET
;
file_lock
.
l_start
=
0
;
file_lock
.
l_len
=
0
;
return
(
fcntl
(
fileno
(
fs
),
F_SETLKW
,
&
file_lock
)
);
}
int
lutil_ldap_unlockf
(
FILE
*
fs
)
{
struct
flock
file_lock
;
memset
(
&
file_lock
,
0
,
sizeof
(
file_lock
)
);
file_lock
.
l_type
=
F_UNLCK
;
file_lock
.
l_whence
=
SEEK_SET
;
file_lock
.
l_start
=
0
;
file_lock
.
l_len
=
0
;
return
(
fcntl
(
fileno
(
fs
),
F_SETLK
,
&
file_lock
)
);
}
#endif
/* !HAVE_FILE_LOCKING */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment