commit faa96ead4451e531ad60840d8eb5ab5bb852fd15
parent 26444bf8df7f80308fb7750b9d0b479d806c82aa
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 30 Jan 2020 16:35:42 +0100
tweaks: correct the description of what nano writes into the lock file
Also, limit the stored program's name to ten bytes. Vim uses four for
its name plus a space, and a maximum of six for its version number.
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -227,19 +227,23 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
*
* byte 0 - 0x62
* byte 1 - 0x30
- * bytes 2-12 - name of program that created the lock
+ * bytes 2-11 - name of program that created the lock
* bytes 24-27 - PID (little endian) of creator process
- * bytes 28-44 - username of who created the lock
- * bytes 68-100 - hostname of where the lock was created
+ * bytes 28-43 - username of who created the lock
+ * bytes 68-99 - hostname of where the lock was created
* bytes 108-876 - filename the lock is for
* byte 1007 - 0x55 if file is modified
* other bytes - 0x00
*
- * This is likely not enough, so this is a WIP. */
+ * Nano does not write the page size (bytes 12-15), nor the modification
+ * time (bytes 16-19), nor the inode of the relevant file (bytes 20-23).
+ * Nano also does not use all available space for user name (40 bytes),
+ * host name (40 bytes), and file name (890 bytes). Nor does nano write
+ * some byte-order-checking numbers (bytes 1008-1022). */
memset(lockdata, 0, lockdatalen);
lockdata[0] = 0x62;
lockdata[1] = 0x30;
- snprintf(&lockdata[2], 11, "nano %s", VERSION);
+ snprintf(&lockdata[2], 10, "nano %s", VERSION);
lockdata[24] = mypid % 256;
lockdata[25] = (mypid / 256) % 256;
lockdata[26] = (mypid / (256 * 256)) % 256;