From 3777c4556029c122ed6c635cae5d458d58205c7f425b2051726ef9741ec3c472 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Mon, 17 Feb 2020 11:23:13 +0000 Subject: [PATCH] Avoid dead locks at login after reboot OBS-URL: https://build.opensuse.org/package/show/shells/tcsh?expand=0&rev=97 --- tcsh-6.22.02-local-dotlock.dif | 82 ++++++++++++++++++++++++++++++++++ tcsh.changes | 6 +++ tcsh.spec | 2 + 3 files changed, 90 insertions(+) create mode 100644 tcsh-6.22.02-local-dotlock.dif diff --git a/tcsh-6.22.02-local-dotlock.dif b/tcsh-6.22.02-local-dotlock.dif new file mode 100644 index 0000000..e4a5e3b --- /dev/null +++ b/tcsh-6.22.02-local-dotlock.dif @@ -0,0 +1,82 @@ +Avoid left over dot lock file after reboot + +--- + dotlock.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 50 insertions(+) + +--- dotlock.c ++++ dotlock.c 2020-02-17 11:16:22.785018224 +0000 +@@ -30,8 +30,38 @@ + #define O_SYNC 0 + #endif + ++#if defined(__linux__) ++# include ++# include ++# ifndef TMPFS_MAGIC ++# define TMPFS_MAGIC 0x01021994 ++# endif ++#endif ++ + #include "dotlock.h" + ++#if defined(__linux__) ++static char *sys_tmpdir; ++static int ++dosys_tmpdir () ++{ ++ static char *shm = "/dev/shm"; ++ struct statfs fs; ++ static int doshm; ++ ++ if (doshm) ++ return (sys_tmpdir != NULL); ++ ++ doshm++; ++ ++ if (statfs(shm, &fs) < 0 || fs.f_type != TMPFS_MAGIC || eaccess(shm, W_OK|X_OK)) ++ return 0; ++ ++ sys_tmpdir = shm; ++ return 1; ++} ++#endif ++ + static int create_exclusive(const char *); + /* + * Create a unique file. O_EXCL does not really work over NFS so we follow +@@ -140,7 +170,17 @@ dot_lock(const char *fname, int pollinte + (void)sigaddset(&nset, SIGTSTP); + (void)sigaddset(&nset, SIGCHLD); + ++#if defined(__linux__) ++ const char *ptr; ++ if ((ptr = strrchr(fname, '/')) && dosys_tmpdir()) { ++ ptr++; ++ fname = ptr; ++ (void)snprintf(path, sizeof(path), "%s/%s.lock", sys_tmpdir, fname); ++ } else ++ (void)snprintf(path, sizeof(path), "%s.lock", fname); ++#else + (void)snprintf(path, sizeof(path), "%s.lock", fname); ++#endif + + retval = -1; + for (;;) { +@@ -174,6 +214,16 @@ dot_unlock(const char *fname) + { + char path[MAXPATHLEN]; + ++#if defined(__linux__) ++ const char *ptr; ++ if ((ptr = strrchr(fname, '/')) && dosys_tmpdir()) { ++ ptr++; ++ fname = ptr; ++ (void)snprintf(path, sizeof(path), "%s/%s.lock", sys_tmpdir, fname); ++ } else ++ (void)snprintf(path, sizeof(path), "%s.lock", fname); ++#else + (void)snprintf(path, sizeof(path), "%s.lock", fname); ++#endif + (void)unlink(path); + } diff --git a/tcsh.changes b/tcsh.changes index b2a0813..be8825f 100644 --- a/tcsh.changes +++ b/tcsh.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Feb 17 11:19:42 UTC 2020 - Dr. Werner Fink + +- Add temporary patch tcsh-6.22.02-local-dotlock.dif to avoid + dead locks at login after a reboot to left dof locking files + ------------------------------------------------------------------- Wed Jan 8 12:06:46 UTC 2020 - Dr. Werner Fink diff --git a/tcsh.spec b/tcsh.spec index bfbde83..e2e7860 100644 --- a/tcsh.spec +++ b/tcsh.spec @@ -33,6 +33,7 @@ Patch4: tcsh-6.18.03-colorls.dif Patch5: tcsh-6.17.06-dspmbyte.dif Patch6: tcsh-6.18.03-catalogs.dif Patch7: tcsh-6.22.02-workaround-common.patch +Patch8: tcsh-6.22.02-local-dotlock.dif BuildRequires: autoconf BuildRequires: fdupes BuildRequires: ncurses-devel @@ -59,6 +60,7 @@ correction, a history mechanism, job control, and a C-like syntax. %patch5 -b .dspmbyte %patch6 -b .catalogs %patch7 -p 1 -b .workaround +%patch8 -p 0 -b .dotlock %patch0 -b .0 %build