Print this page
make: unifdef for other OSes (undefined)


  20  */
  21 /*
  22  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #include <avo/intl.h>     /* for NOCATGETS */
  27 #include <stdio.h>
  28 #include <stdlib.h>
  29 #include <string.h>
  30 #include <sys/errno.h>
  31 #include <sys/param.h>
  32 #include <sys/stat.h>
  33 #include <sys/types.h>
  34 #include <unistd.h>
  35 #include <vroot/vroot.h>
  36 #include <mksdmsi18n/mksdmsi18n.h>
  37 #include <signal.h>
  38 #include <errno.h>                        /* errno */
  39 
  40 #if !defined(linux)
  41 extern  char            *sys_errlist[];
  42 extern  int             sys_nerr;
  43 #endif
  44 
  45 static  void            file_lock_error(char *msg, char *file, char *str, int arg1, int arg2);
  46 
  47 #define BLOCK_INTERUPTS sigfillset(&newset) ; \
  48         sigprocmask(SIG_SETMASK, &newset, &oldset)
  49 
  50 #define UNBLOCK_INTERUPTS \
  51         sigprocmask(SIG_SETMASK, &oldset, &newset)
  52 
  53 /*
  54  * This code stolen from the NSE library and changed to not depend
  55  * upon any NSE routines or header files.
  56  *
  57  * Simple file locking.
  58  * Create a symlink to a file.  The "test and set" will be
  59  * atomic as creating the symlink provides both functions.
  60  *
  61  * The timeout value specifies how long to wait for stale locks
  62  * to disappear.  If the lock is more than 'timeout' seconds old
  63  * then it is ok to blow it away.  This part has a small window


 151                                  */
 152                                 return EEXIST;
 153                         }
 154                 }
 155         }
 156         /* NOTREACHED */
 157 }
 158 
 159 /*
 160  * Format a message telling why the lock could not be created.
 161  */
 162 static  void
 163 file_lock_error(char *msg, char *file, char *str, int arg1, int arg2)
 164 {
 165         int             len;
 166 
 167         sprintf(msg, catgets(libmksdmsi18n_catd, 1, 145, "Could not lock file `%s'; "), file);
 168         len = strlen(msg);
 169         sprintf(&msg[len], str, arg1, arg2);
 170         strcat(msg, catgets(libmksdmsi18n_catd, 1, 146, " failed - "));
 171 #if !defined(linux)
 172         if (errno < sys_nerr) {
 173 #ifdef SUN4_x
 174                 strcat(msg, sys_errlist[errno]);
 175 #endif
 176                 strcat(msg, strerror(errno));
 177         } else {
 178                 len = strlen(msg);
 179                 sprintf(&msg[len], NOCATGETS("errno %d"), errno);
 180         }
 181 #else
 182         strcat(msg, strerror(errno));
 183 #endif
 184 }
 185 


  20  */
  21 /*
  22  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #include <avo/intl.h>     /* for NOCATGETS */
  27 #include <stdio.h>
  28 #include <stdlib.h>
  29 #include <string.h>
  30 #include <sys/errno.h>
  31 #include <sys/param.h>
  32 #include <sys/stat.h>
  33 #include <sys/types.h>
  34 #include <unistd.h>
  35 #include <vroot/vroot.h>
  36 #include <mksdmsi18n/mksdmsi18n.h>
  37 #include <signal.h>
  38 #include <errno.h>                        /* errno */
  39 

  40 extern  char            *sys_errlist[];
  41 extern  int             sys_nerr;

  42 
  43 static  void            file_lock_error(char *msg, char *file, char *str, int arg1, int arg2);
  44 
  45 #define BLOCK_INTERUPTS sigfillset(&newset) ; \
  46         sigprocmask(SIG_SETMASK, &newset, &oldset)
  47 
  48 #define UNBLOCK_INTERUPTS \
  49         sigprocmask(SIG_SETMASK, &oldset, &newset)
  50 
  51 /*
  52  * This code stolen from the NSE library and changed to not depend
  53  * upon any NSE routines or header files.
  54  *
  55  * Simple file locking.
  56  * Create a symlink to a file.  The "test and set" will be
  57  * atomic as creating the symlink provides both functions.
  58  *
  59  * The timeout value specifies how long to wait for stale locks
  60  * to disappear.  If the lock is more than 'timeout' seconds old
  61  * then it is ok to blow it away.  This part has a small window


 149                                  */
 150                                 return EEXIST;
 151                         }
 152                 }
 153         }
 154         /* NOTREACHED */
 155 }
 156 
 157 /*
 158  * Format a message telling why the lock could not be created.
 159  */
 160 static  void
 161 file_lock_error(char *msg, char *file, char *str, int arg1, int arg2)
 162 {
 163         int             len;
 164 
 165         sprintf(msg, catgets(libmksdmsi18n_catd, 1, 145, "Could not lock file `%s'; "), file);
 166         len = strlen(msg);
 167         sprintf(&msg[len], str, arg1, arg2);
 168         strcat(msg, catgets(libmksdmsi18n_catd, 1, 146, " failed - "));

 169         if (errno < sys_nerr) {



 170                 strcat(msg, strerror(errno));
 171         } else {
 172                 len = strlen(msg);
 173                 sprintf(&msg[len], NOCATGETS("errno %d"), errno);
 174         }



 175 }
 176