Skip to content

Instantly share code, notes, and snippets.

View briangreenery's full-sized avatar

Brian Green briangreenery

  • Berkeley, CA
  • 17:30 (UTC -08:00)
View GitHub Profile
@briangreenery
briangreenery / statvfs.c
Last active December 29, 2015 09:28
Calculate the free size of a directory using statvfs and statvfs64
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/statvfs.h>
static int print_bytes_free_32( const char* directory )
{
struct statvfs buf32;
if ( statvfs( directory, &buf32 ) == -1 )
@briangreenery
briangreenery / free_size.c
Created November 23, 2013 00:09
(Incorrectly) calculate the free size of the directory
#include <stdio.h>
#include <inttypes.h>
#include <sys/statvfs.h>
typedef unsigned long long uint64;
uint64 get_free_size( const char* path )
{
struct statvfs buffer;
if ( statvfs( path, &buffer ) != -1 )
#include <stdio.h>
#include <utmp.h>
int main()
{
setutent();
struct utmp* entry;
for ( entry = getutent(); entry; entry = getutent() )
{
@briangreenery
briangreenery / set_password_policy.sh
Last active December 29, 2015 03:09
Set the console user password policy on a linux server
#!/bin/sh
# The location of the iem tool
IEM=/opt/BESServer/bin/iem
# The password regex
REGEX="A+B+"
# The password description
DESCRIPTION="Your password needs some As then some Bs"