Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
7b92975f
Commit
7b92975f
authored
Nov 17, 1994
by
Richard M. Stallman
Browse files
(lock_dir, superlock_file, MAKE_LOCK_NAME):
Renamed from lock_path, superlock_path, MAKE_LOCK_PATH.
parent
dc554c3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
31 deletions
+31
-31
src/filelock.c
src/filelock.c
+31
-31
No files found.
src/filelock.c
View file @
7b92975f
...
...
@@ -77,23 +77,23 @@ extern struct passwd *getpwuid ();
/* The name of the directory in which we keep lock files, with a '/'
appended. */
char
*
lock_
path
;
char
*
lock_
dir
;
/* The name of the file in the lock directory which is used to
arbitrate access to the entire directory. */
#define SUPERLOCK_NAME "!!!SuperLock!!!"
/* The
path to
the superlock file. This is SUPERLOCK_NAME appended to
lock_
path
. */
char
*
superlock_
path
;
/* The
name of
the superlock file. This is SUPERLOCK_NAME appended to
lock_
dir
. */
char
*
superlock_
file
;
/* Set LOCK to the name of the lock file for the filename FILE.
char *LOCK; Lisp_Object FILE; */
#ifndef HAVE_LONG_FILE_NAMES
#define MAKE_LOCK_
PATH
(lock, file) \
(lock = (char *) alloca (14 + strlen (lock_
path
) + 1), \
#define MAKE_LOCK_
NAME
(lock, file) \
(lock = (char *) alloca (14 + strlen (lock_
dir
) + 1), \
fill_in_lock_short_file_name (lock, (file)))
...
...
@@ -124,15 +124,15 @@ fill_in_lock_short_file_name (lockfile, fn)
crc
.
byte
[
1
]
=
crc
.
byte
[
0
];
crc
.
byte
[
0
]
=
new
;
}
sprintf
(
lockfile
,
"%s%.2x%.2x%.2x%.2x%.2x%.2x%.2x"
,
lock_
path
,
sprintf
(
lockfile
,
"%s%.2x%.2x%.2x%.2x%.2x%.2x%.2x"
,
lock_
dir
,
crc
.
byte
[
0
],
crc
.
byte
[
1
],
crc
.
byte
[
2
],
crc
.
byte
[
3
],
crc
.
byte
[
4
],
crc
.
byte
[
5
],
crc
.
byte
[
6
]);
}
#else
/* defined HAVE_LONG_FILE_NAMES */
#define MAKE_LOCK_
PATH
(lock, file) \
(lock = (char *) alloca (XSTRING (file)->size + strlen (lock_
path
) + 1), \
#define MAKE_LOCK_
NAME
(lock, file) \
(lock = (char *) alloca (XSTRING (file)->size + strlen (lock_
dir
) + 1), \
fill_in_lock_file_name (lock, (file)))
...
...
@@ -142,7 +142,7 @@ fill_in_lock_file_name (lockfile, fn)
{
register
char
*
p
;
strcpy
(
lockfile
,
lock_
path
);
strcpy
(
lockfile
,
lock_
dir
);
p
=
lockfile
+
strlen
(
lockfile
);
...
...
@@ -202,7 +202,7 @@ lock_file (fn)
register
Lisp_Object
attack
;
register
char
*
lfname
;
MAKE_LOCK_
PATH
(
lfname
,
fn
);
MAKE_LOCK_
NAME
(
lfname
,
fn
);
/* See if this file is visited and has changed on disk since it was
visited. */
...
...
@@ -228,7 +228,7 @@ lock_file (fn)
{
lock_superlock
(
lfname
);
lock_file_1
(
lfname
,
O_WRONLY
)
;
unlink
(
superlock_
path
);
unlink
(
superlock_
file
);
return
;
}
/* User says ignore the lock */
...
...
@@ -329,14 +329,14 @@ unlock_file (fn)
{
register
char
*
lfname
;
MAKE_LOCK_
PATH
(
lfname
,
fn
);
MAKE_LOCK_
NAME
(
lfname
,
fn
);
lock_superlock
(
lfname
);
if
(
current_lock_owner_1
(
lfname
)
==
getpid
())
unlink
(
lfname
);
unlink
(
superlock_
path
);
unlink
(
superlock_
file
);
}
lock_superlock
(
lfname
)
...
...
@@ -345,7 +345,7 @@ lock_superlock (lfname)
register
int
i
,
fd
;
DIR
*
lockdir
;
for
(
i
=
-
20
;
i
<
0
&&
(
fd
=
open
(
superlock_
path
,
for
(
i
=
-
20
;
i
<
0
&&
(
fd
=
open
(
superlock_
file
,
O_WRONLY
|
O_EXCL
|
O_CREAT
,
0666
))
<
0
;
i
++
)
{
...
...
@@ -355,7 +355,7 @@ lock_superlock (lfname)
/* This seems to be necessary to prevent Emacs from hanging when the
competing process has already deleted the superlock, but it's still
in the NFS cache. So we force NFS to synchronize the cache. */
if
(
lockdir
=
opendir
(
lock_
path
))
if
(
lockdir
=
opendir
(
lock_
dir
))
closedir
(
lockdir
);
sleep
(
1
);
...
...
@@ -363,7 +363,7 @@ lock_superlock (lfname)
if
(
fd
>=
0
)
{
#ifdef USG
chmod
(
superlock_
path
,
0666
);
chmod
(
superlock_
file
,
0666
);
#else
fchmod
(
fd
,
0666
);
#endif
...
...
@@ -439,7 +439,7 @@ t if it is locked by you, else a string of the name of the locker.")
fn
=
Fexpand_file_name
(
fn
,
Qnil
);
MAKE_LOCK_
PATH
(
lfname
,
fn
);
MAKE_LOCK_
NAME
(
lfname
,
fn
);
owner
=
current_lock_owner
(
lfname
);
if
(
owner
<=
0
)
...
...
@@ -455,25 +455,25 @@ t if it is locked by you, else a string of the name of the locker.")
init_filelock
()
{
char
*
new_
path
char
*
new_
name
lock_
path
=
egetenv
(
"EMACSLOCKDIR"
);
if
(
!
lock_
path
)
lock_
path
=
PATH_LOCK
;
lock_
dir
=
egetenv
(
"EMACSLOCKDIR"
);
if
(
!
lock_
dir
)
lock_
dir
=
PATH_LOCK
;
/* Copy the
path
in case egetenv got it from a Lisp string. */
new_
path
=
(
char
*
)
xmalloc
(
strlen
(
lock_
path
)
+
2
);
strcpy
(
new_
path
,
lock_
path
);
lock_
path
=
new_
path
;
/* Copy the
name
in case egetenv got it from a Lisp string. */
new_
name
=
(
char
*
)
xmalloc
(
strlen
(
lock_
dir
)
+
2
);
strcpy
(
new_
name
,
lock_
dir
);
lock_
dir
=
new_
name
;
/* Make sure it ends with a slash. */
if
(
lock_
path
[
strlen
(
lock_
path
)
-
1
]
!=
'/'
)
strcat
(
lock_
path
,
"/"
);
if
(
lock_
dir
[
strlen
(
lock_
dir
)
-
1
]
!=
'/'
)
strcat
(
lock_
dir
,
"/"
);
superlock_
path
=
(
char
*
)
xmalloc
((
strlen
(
lock_
path
)
superlock_
file
=
(
char
*
)
xmalloc
((
strlen
(
lock_
dir
)
+
sizeof
(
SUPERLOCK_NAME
)));
strcpy
(
superlock_
path
,
lock_
path
);
strcat
(
superlock_
path
,
SUPERLOCK_NAME
);
strcpy
(
superlock_
file
,
lock_
dir
);
strcat
(
superlock_
file
,
SUPERLOCK_NAME
);
}
syms_of_filelock
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment