loadYOURSELF

loadYOURSELF

Browsing Posts tagged usage

The CLI way

The df utility displays the disk space usage on all mounted filesystems. The -T option prints the filesystem type as well. By default, df measures the size in 1K blocks, which could be a little difficult for a desktop user to decipher. Use the -h option to get more understandable output:

$ df -h -T
Filesystem Type Size Used Avail Use% Mounted on
/dev/hda6 ext3 20G 9.3G 9.1G 51% /
/dev/hda7 reiserfs 13G 2.1G 11G 17% /mnt/suse
/dev/sda1 vfat 241M 152M 90M 63% /media/usbdisk

Shared library file
b.c

#include

void b_printer ()
{
printf (“Printing something from a shared library.n”);
}

gcc -fPIC -shared -o b.so b.c

Prototypes for the Shared Library Functions Found in dlfcn.h

void* dlopen (const char* filename, int flag);
const char* dlerror (void);
void* dlsym (void* handle, char* symbol);

  1. Open the shared library by using dlopen().
  2. Check that the open succeeded by using dlerror().
  3. Get the function that you want by using dlsym().