Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Main
Synchronet
Commits
eea45ad8
Commit
eea45ad8
authored
24 years ago
by
cmartin
Browse files
Options
Downloads
Patches
Plain Diff
Added lock()/unlock() and sopen() for unix
parent
a924e1d6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/smbwrap.c
+41
-6
41 additions, 6 deletions
src/sbbs3/smbwrap.c
with
41 additions
and
6 deletions
src/sbbs3/smbwrap.c
+
41
−
6
View file @
eea45ad8
...
...
@@ -40,6 +40,8 @@
#include
<glob.h>
/* glob() wildcard matching */
#include
<string.h>
/* strlen() */
#include
<unistd.h>
/* getpid() */
#include
<fcntl.h>
/* fcntl() file/record locking */
#endif
...
...
@@ -133,9 +135,6 @@ BOOL SMBCALL fexist(char *filespec)
#if defined(__unix__)
#include
<unistd.h>
#include
<fcntl.h>
/****************************************************************************/
/* Returns the length of the file in 'fd' */
/****************************************************************************/
...
...
@@ -152,19 +151,55 @@ long filelength(int fd)
/* Sets a lock on a portion of a file */
int
lock
(
int
fd
,
long
pos
,
int
len
)
{
return
0
;
struct
flock
alock
;
alock
.
l_type
=
F_WRLCK
;
// set a write lock to prevent all access
alock
.
l_whence
=
L_SET
;
// SEEK_SET
alock
.
l_start
=
pos
;
alock
.
l_len
=
len
;
alock
.
l_pid
=
getpid
();
// current process ID
return
fcntl
(
fd
,
F_SETLK
,
&
alock
);
}
/* Removes a lock from a file record */
int
unlock
(
int
fd
,
long
pos
,
int
len
)
{
return
0
;
struct
flock
alock
;
alock
.
l_type
=
F_UNLCK
;
// remove the lock
alock
.
l_whence
=
L_SET
;
alock
.
l_start
=
pos
;
alock
.
l_len
=
len
;
alock
.
l_pid
=
getpid
();
// current process ID
return
fcntl
(
fd
,
F_SETLK
,
&
alock
);
}
/* Opens a file in specified sharing (file-locking) mode */
int
sopen
(
char
*
fn
,
int
access
,
int
share
)
{
return
(
open
(
fn
,
access
,
S_IREAD
|
S_IWRITE
));
int
fd
;
struct
flock
alock
;
if
((
fd
=
open
(
fn
,
access
))
<
0
)
return
-
1
;
if
(
share
==
SH_DENYNO
)
// no lock needed
return
fd
;
alock
.
l_type
=
share
;
alock
.
l_whence
=
L_SET
;
alock
.
l_start
=
0
;
alock
.
l_len
=
0
;
// lock to EOF
alock
.
l_pid
=
getpid
();
if
(
fcntl
(
fd
,
F_SETLK
,
&
alock
)
<
0
)
{
close
(
fd
);
return
-
1
;
}
return
fd
;
}
#elif defined _MSC_VER || defined __MINGW32__
...
...
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