diff --git a/src/files.c b/src/files.c index 4f3d6b22..f15a05f8 100644 --- a/src/files.c +++ b/src/files.c @@ -116,7 +116,7 @@ void initialize_buffer_text(void) origfilename: name of the file the lock is for modified: whether to set the modified bit in the file - Returns: 1 on success, -1 on failure + Returns: 1 on success, 0 on failure (but continue loading), -1 on failure and abort */ int write_lockfile(const char *lockfilename, const char *origfilename, bool modified) { @@ -154,6 +154,13 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi fd = open(lockfilename, cflags, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + + /* Maybe we just don't have write access, don't stop us from + opening the file at all, just don't set the lock_filename + and return success */ + if (fd < 0 && errno == EACCES) + return 1; + /* Now we've got a safe file stream. If the previous open() call failed, this will return NULL. */ filestream = fdopen(fd, "wb"); @@ -232,7 +239,9 @@ int delete_lockfile(const char *lockfilename) /* Deal with lockfiles. Return -1 on refusing to override - the lock file, and 1 on successfully created the lockfile. + the lock file, and 1 on successfully created the lockfile, 0 means + we were not successful on creating the lockfile but we should + continue to load the file and complain to the user. */ int do_lockfile(const char *filename) { diff --git a/src/winio.c b/src/winio.c index 29a74f2b..68692324 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2258,6 +2258,12 @@ void set_modified(void) if (!openfile->modified) { openfile->modified = TRUE; titlebar(NULL); +#ifndef NANO_TINY + if (ISSET(LOCKING) && openfile->lock_filename == NULL) + /* Translators: Try to keep this at most 80 characters. */ + statusbar(_("Warning: Modifying a file which is not locked, check directory permission?")); +#endif + } }