Exemple #1
0
/*---------------------------------------------------------------------*/
BGL_RUNTIME_DEF int
bgl_symlink( char *s1, char *s2 ) {
#if BGL_HAVE_SYMLINK   
   if( symlink( s1, s2 ) ) {
      C_SYSTEM_FAILURE( BGL_IO_ERROR, "make-symlink", strerror( errno ),
			string_to_bstring( s2 ) );
   }

   return 0;
#else
   C_SYSTEM_FAILURE( BGL_IO_ERROR, "make-symlink", "Not supported",
		     string_to_bstring( s2 ) );
   return 1;
#endif   
}
Exemple #2
0
/*---------------------------------------------------------------------*/
BGL_RUNTIME_DEF int
bgl_setgid( gid_t gid ) {
#if BGL_HAVE_GETGID
   if( !setgid( gid ) ) {
      return gid;
   } else {
      C_SYSTEM_FAILURE( BGL_ERROR, "setgid", strerror( errno ), BINT( gid ) );
      return gid;
   }
#else
      C_SYSTEM_FAILURE( BGL_ERROR, "setgid",
			"operation not supported", BINT( gid ) );
      return gid;
#endif
}
Exemple #3
0
/*---------------------------------------------------------------------*/
int
bgl_utime( char *file, long atime, long mtime ) {
   struct utimbuf buf = { .actime = (time_t)atime, .modtime= (time_t)mtime };
   int r = utime( file, &buf );
   
   if( r < 0 ) {
      C_SYSTEM_FAILURE( BGL_ERROR, "file-times-set!",
			strerror( errno ),
			string_to_bstring( file ) );
   }
   return r;
}
Exemple #4
0
/*---------------------------------------------------------------------*/
BGL_RUNTIME_DEF obj_t
bgl_getgroups() {
#if BGL_HAVE_GETGROUPS
   int ngroups = getgroups( 0, 0L );

  if( ngroups == -1 ) {
     C_SYSTEM_FAILURE( BGL_IO_ERROR, "getgroups", strerror( errno ), BFALSE );
  } else {
     gid_t* groups = alloca( sizeof( gid_t ) * ngroups );

     ngroups = getgroups( ngroups, groups );

     if( ngroups == -1 ) {
	C_SYSTEM_FAILURE( BGL_IO_ERROR, "getgroups", strerror( errno ), BFALSE );
     } else {
	obj_t res = create_vector( ngroups + 1 );
	gid_t egid = getegid();
	int seen_egid = 0;
	int i;

	for( i = 0; i < ngroups; i++ ) {
	   VECTOR_SET( res, i, BINT( groups[ i ] ) );
	   if( groups[ i ] == egid ) seen_egid = 1;
	}
	
	if( seen_egid ) {
	   VECTOR( res ).length--;
	} else {
	   VECTOR_SET( res, i, BINT( egid ) );
	}

	return res;
     }
  }
#else
      return create_vector( 0 );
#endif
}
Exemple #5
0
/*---------------------------------------------------------------------*/
BGL_RUNTIME_DEF BGL_LONGLONG_T
bgl_current_microseconds() {
#if( BGL_HAVE_TIMEVAL )   
   struct timeval tv;
   if( gettimeofday( &tv, 0 ) == 0 ) {
      return (BGL_LONGLONG_T)(tv.tv_sec) * 1000000 +
	 (BGL_LONGLONG_T)(tv.tv_usec);
   } else {
      C_SYSTEM_FAILURE( BGL_ERROR,
			"current-microseconds",
			strerror( errno ),
			BUNSPEC );
   }
#else
   return (BGL_LONGLONG_T)(bgl_current_seconds() ) * 1000000;
#endif
}
Exemple #6
0
static void
odbc_error( char *who, char *message, obj_t object ) 
{
  C_SYSTEM_FAILURE( BGL_ERROR, who, message, object );
}