aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filelock.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 8fb41a3d7eb..02b3ccc8b05 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -311,9 +311,11 @@ typedef struct
311 311
312 312
313/* Write the name of the lock file for FN into LFNAME. Length will be 313/* Write the name of the lock file for FN into LFNAME. Length will be
314 that of FN plus two more for the leading `.#' plus one for the null. */ 314 that of FN plus two more for the leading `.#' plus 1 for the
315 trailing period plus one for the digit after it plus one for the
316 null. */
315#define MAKE_LOCK_NAME(lock, file) \ 317#define MAKE_LOCK_NAME(lock, file) \
316 (lock = (char *) alloca (STRING_BYTES (XSTRING (file)) + 2 + 1), \ 318 (lock = (char *) alloca (STRING_BYTES (XSTRING (file)) + 2 + 1 + 1 + 1), \
317 fill_in_lock_file_name (lock, (file))) 319 fill_in_lock_file_name (lock, (file)))
318 320
319static void 321static void
@@ -322,6 +324,8 @@ fill_in_lock_file_name (lockfile, fn)
322 register Lisp_Object fn; 324 register Lisp_Object fn;
323{ 325{
324 register char *p; 326 register char *p;
327 struct stat st;
328 int count = 0;
325 329
326 strcpy (lockfile, XSTRING (fn)->data); 330 strcpy (lockfile, XSTRING (fn)->data);
327 331
@@ -334,6 +338,18 @@ fill_in_lock_file_name (lockfile, fn)
334 /* Insert the `.#'. */ 338 /* Insert the `.#'. */
335 p[1] = '.'; 339 p[1] = '.';
336 p[2] = '#'; 340 p[2] = '#';
341
342 p = p + strlen (p);
343
344 while (lstat (lockfile, &st) == 0 && !S_ISLNK (st.st_mode))
345 {
346 if (count > 9)
347 {
348 *p = '\0';
349 return;
350 }
351 sprintf (p, ".%d", count++);
352 }
337} 353}
338 354
339/* Lock the lock file named LFNAME. 355/* Lock the lock file named LFNAME.