summaryrefslogtreecommitdiff
path: root/src/filelock.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1993-06-07 05:30:29 +0000
committerRichard M. Stallman <rms@gnu.org>1993-06-07 05:30:29 +0000
commit118433cdf27dca7c9d6bc8ae9b74bc3372ec307b (patch)
tree73f52fe32b8a5e7b8687c496d4dd1729d9ae4854 /src/filelock.c
parentfa8de72584b5b12e603e5fcb1e8b3bf4a1483ffd (diff)
downloademacs-118433cdf27dca7c9d6bc8ae9b74bc3372ec307b.tar.gz
(MAKE_LOCK_PATH): If SHORT_FILE_NAMES allocates
different space and calls fill_in_lock_short_file_name. (fill_in_lock_short_file_name): New function for 14-chars hashed file names. Replaces fill_in_lock_file_name if SHORT_FILE_NAMES.
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/filelock.c b/src/filelock.c
index fad8dd15171..5b31acbcb16 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -66,10 +66,54 @@ char *superlock_path;
/* Set LOCK to the name of the lock file for the filename FILE.
char *LOCK; Lisp_Object FILE; */
+
+#ifdef SHORT_FILE_NAMES
+
+#define MAKE_LOCK_PATH(lock, file) \
+ (lock = (char *) alloca (14 + strlen (lock_path) + 1), \
+ fill_in_lock_short_file_name (lock, (file)))
+
+
+fill_in_lock_short_file_name (lockfile, fn)
+ register char *lockfile;
+ register Lisp_Object fn;
+{
+ register union
+ {
+ unsigned int word [2];
+ unsigned char byte [8];
+ } crc;
+ register unsigned char *p, new;
+
+ /* 7-bytes cyclic code for burst correction on byte-by-byte basis.
+ the used polynomial is D^7 + D^6 + D^3 +1. pot@cnuce.cnr.it */
+
+ crc.word[0] = crc.word[1] = 0;
+
+ for (p = XSTRING (fn)->data; new = *p++; )
+ {
+ new += crc.byte[7];
+ crc.byte[7] = crc.byte[6];
+ crc.byte[6] = crc.byte[5] + new;
+ crc.byte[5] = crc.byte[4];
+ crc.byte[4] = crc.byte[3];
+ crc.byte[3] = crc.byte[2] + new;
+ crc.byte[2] = crc.byte[1];
+ crc.byte[1] = crc.byte[0];
+ crc.byte[0] = new;
+ }
+ sprintf (lockfile, "%s%.2x%.2x%.2x%.2x%.2x%.2x%.2x", lock_path,
+ crc.byte[0], crc.byte[1], crc.byte[2], crc.byte[3],
+ crc.byte[4], crc.byte[5], crc.byte[6]);
+}
+
+#else /* !defined SHORT_FILE_NAMES */
+
#define MAKE_LOCK_PATH(lock, file) \
(lock = (char *) alloca (XSTRING (file)->size + strlen (lock_path) + 1), \
fill_in_lock_file_name (lock, (file)))
+
fill_in_lock_file_name (lockfile, fn)
register char *lockfile;
register Lisp_Object fn;
@@ -88,6 +132,7 @@ fill_in_lock_file_name (lockfile, fn)
*p = '!';
}
}
+#endif /* SHORT_FILE_NAMES */
static Lisp_Object
lock_file_owner_name (lfname)
@@ -124,6 +169,11 @@ lock_file_owner_name (lfname)
and put in the Emacs lock directory. */
/* (ie., /ka/king/junk.tex -> /!/!ka!king!junk.tex). */
+/* If SHORT_FILE_NAMES is defined, the lock file name is the hex
+ representation of a 14-bytes CRC generated from the file name
+ and put in the Emacs lock directory (not very nice, but it works).
+ (ie., /ka/king/junk.tex -> /!/ec92d3ed24a8f0). */
+
void
lock_file (fn)
register Lisp_Object fn;