2b15d05
Description: <short summary of the patch>
2b15d05
 TODO: Put a short summary on the line above and replace this paragraph
2b15d05
 with a longer explanation of this change. Complete the meta-information
2b15d05
 with other relevant fields (see below for details). To make it easier, the
2b15d05
 information below has been extracted from the changelog. Adjust it or drop
2b15d05
 it.
2b15d05
 .
2b15d05
 gcl (2.6.12-90) unstable; urgency=medium
2b15d05
 .
2b15d05
   * Version_2_6_13pre87
2b15d05
   * latest standards
2b15d05
Author: Camm Maguire <camm@debian.org>
2b15d05
2b15d05
---
2b15d05
The information above should follow the Patch Tagging Guidelines, please
2b15d05
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
2b15d05
are templates for supplementary fields that you might want to add:
2b15d05
2b15d05
Origin: <vendor|upstream|other>, <url of original patch>
2b15d05
Bug: <url in upstream bugtracker>
2b15d05
Bug-Debian: https://bugs.debian.org/<bugnumber>
2b15d05
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
2b15d05
Forwarded: <no|not-needed|url proving that it has been forwarded>
2b15d05
Reviewed-By: <name and email of someone who approved the patch>
2b15d05
Last-Update: 2019-12-18
2b15d05
2b15d05
--- gcl-2.6.12.orig/h/pool.h
2b15d05
+++ gcl-2.6.12/h/pool.h
2b15d05
@@ -20,9 +20,8 @@ static struct pool {
2b15d05
   ufixnum s;
2b15d05
 } *Pool;
2b15d05
 
2b15d05
-static struct flock pl,*plp=&pl;
2b15d05
-
2b15d05
-static const char *gcl_pool="/tmp/gcl_pool";
2b15d05
+static struct flock f,pl,*plp=&pl;
2b15d05
+static char gcl_pool[PATH_MAX];
2b15d05
 
2b15d05
 static int
2b15d05
 set_lock(void) {
2b15d05
@@ -66,8 +65,8 @@ open_pool(void) {
2b15d05
 
2b15d05
   if (pool==-1) {
2b15d05
 
2b15d05
-    struct flock f;
2b15d05
-
2b15d05
+    massert(!home_namestring1("~",1,FN1,sizeof(FN1)));
2b15d05
+    massert(snprintf(gcl_pool,sizeof(gcl_pool),"%sgcl_pool",FN1)>=0);
2b15d05
     massert((pool=open(gcl_pool,O_CREAT|O_RDWR,0644))!=-1);
2b15d05
     massert(!ftruncate(pool,sizeof(struct pool)));
2b15d05
     massert((Pool=mmap(NULL,sizeof(struct pool),PROT_READ|PROT_WRITE,MAP_SHARED,pool,0))!=(void *)-1);
2b15d05
@@ -111,6 +110,9 @@ close_pool(void) {
2b15d05
 
2b15d05
 #ifndef NO_FILE_LOCKING
2b15d05
   if (pool!=-1) {
2b15d05
+    f.l_type=F_WRLCK;
2b15d05
+    if (!fcntl(pool,F_SETLK,&f))
2b15d05
+      massert(!unlink(gcl_pool));
2b15d05
     register_pool(-1);
2b15d05
     massert(!close(pool));
2b15d05
     massert(!munmap(Pool,sizeof(struct pool)));
2b15d05
--- gcl-2.6.12.orig/h/protoize.h
2b15d05
+++ gcl-2.6.12/h/protoize.h
2b15d05
@@ -1971,3 +1971,6 @@ travel_find_sharing(object,object);
2b15d05
 
2b15d05
 object
2b15d05
 new_cfdata(void);
2b15d05
+
2b15d05
+int
2b15d05
+home_namestring1(const char *,int,char *,int);
2b15d05
--- gcl-2.6.12.orig/o/unixfsys.c
2b15d05
+++ gcl-2.6.12/o/unixfsys.c
2b15d05
@@ -95,16 +95,20 @@ DEFUN_NEW("UID-TO-NAME",object,fSuid_to_
2b15d05
 #endif
2b15d05
 }
2b15d05
 
2b15d05
-DEFUN_NEW("HOME-NAMESTRING",object,fShome_namestring,SI,1,1,NONE,OO,OO,OO,OO,(object nm),"") {
2b15d05
+int
2b15d05
+home_namestring1(const char *n,int s,char *o,int so) {
2b15d05
 
2b15d05
-#ifndef __MINGW32__
2b15d05
+  #ifndef __MINGW32__
2b15d05
   struct passwd *pwent,pw;
2b15d05
   long r;
2b15d05
 
2b15d05
+  massert(s>0);
2b15d05
+  massert(*n=='~');
2b15d05
+
2b15d05
   massert((r=sysconf(_SC_GETPW_R_SIZE_MAX))>=0);
2b15d05
   massert(r<=sizeof(GETPW_BUF));/*FIXME maybe once at image startup*/
2b15d05
 
2b15d05
-  if (nm->st.st_fillp==1)
2b15d05
+  if (s==1)
2b15d05
 
2b15d05
     if ((pw.pw_dir=getenv("HOME")))
2b15d05
       pwent=&pw;
2b15d05
@@ -113,26 +117,44 @@ DEFUN_NEW("HOME-NAMESTRING",object,fShom
2b15d05
 
2b15d05
   else {
2b15d05
 
2b15d05
-    massert(nm->st.st_fillp
2b15d05
-    memcpy(FN2,nm->st.st_self+1,nm->st.st_fillp-1);
2b15d05
-    FN2[nm->st.st_fillp-1]=0;
2b15d05
+    massert(s
2b15d05
+    memcpy(FN2,n+1,s-1);
2b15d05
+    FN2[s-1]=0;
2b15d05
 
2b15d05
     massert(!getpwnam_r(FN2,&pw,GETPW_BUF,r,&pwent) && pwent);
2b15d05
 
2b15d05
   }
2b15d05
 
2b15d05
-  massert((r=strlen(pwent->pw_dir))+2
2b15d05
-  memcpy(FN3,pwent->pw_dir,r);
2b15d05
-  FN3[r]='/';
2b15d05
-  FN3[r+1]=0;
2b15d05
-  RETURN1(make_simple_string(FN3));
2b15d05
+  massert((r=strlen(pwent->pw_dir))+2
2b15d05
+  memcpy(o,pwent->pw_dir,r);
2b15d05
+  o[r]='/';
2b15d05
+  o[r+1]=0;
2b15d05
+  return 0;
2b15d05
 #else
2b15d05
-  massert(snprintf(FN1,sizeof(FN1)-1,"%s%s",getenv("SystemDrive"),getenv("HOMEPATH"))>=0);
2b15d05
-  RETURN1(make_simple_string(FN1));
2b15d05
+  massert(snprintf(o,so-1,"%s%s",getenv("SystemDrive"),getenv("HOMEPATH"))>=0);
2b15d05
+  return 0;
2b15d05
 #endif
2b15d05
 
2b15d05
 }
2b15d05
 
2b15d05
+
2b15d05
+DEFUN_NEW("HOME-NAMESTRING",object,fShome_namestring,SI,1,1,NONE,OO,OO,OO,OO,(object nm),"") {
2b15d05
+
2b15d05
+  check_type_string(&nm);
2b15d05
+
2b15d05
+  massert(!home_namestring1(nm->st.st_self,nm->st.st_fillp,FN1,sizeof(FN1)));
2b15d05
+  RETURN1(make_simple_string(FN1));
2b15d05
+
2b15d05
+}
2b15d05
+#ifdef STATIC_FUNCTION_POINTERS
2b15d05
+object
2b15d05
+fShome_namestring(object x) {
2b15d05
+  return FFN(fShome_namestring)(x);
2b15d05
+}
2b15d05
+#endif
2b15d05
+
2b15d05
+
2b15d05
+
2b15d05
 #define FILE_EXISTS_P(a_,b_) !stat(a_,&b_) && S_ISREG(b_.st_mode)
2b15d05
 #define DIR_EXISTS_P(a_,b_) !stat(a_,&b_) && S_ISDIR(b_.st_mode)
2b15d05