Tuesday, December 10, 2013

Saturday, December 7, 2013

ZFS Commands

Pool related :

#zpool create [name] [type = mirror, raidz, log, cache, sparse] [disk, file]

#zpool status

#zpool destroy

#zpool scrub

#zpool import | export

#zpool online | offline [device]

#zpool attach | detach [mirror]

#zpool cache

#zpool add pool [type]

#zpool get all

#zpool set [property=value] [pool]

#zpool history

Dataset (Volumn / Filesystem) related :

#zfs create [pool]/[dataset]

#zfs get all [pool]/[dataset]

#zfs set [property=value] [pool]/[dataset]

#zfs list

#zfs snapshot [pool]/[dataset]@[name]

#zfs rollback

#zfs clone

#zfs send | receive

Debugging :


Thursday, January 3, 2013

Using LLVM based Go compiler - llgo

We are going to use llgo - a compiler for Go, written in Go, and using the LLVM compiler infrastructure. The project is hosted at https://github.com/axw/llgo

1. Install LLVM from source using this guide http://linuxdeveloper.blogspot.in/2012/12/building-llvm-32-from-source.html

2. Download Go 1.0.3 binary packages from http://code.google.com/p/go/downloads/list. The file is named "go1.0.3.linux-amd64.tar.gz" and you have to download it in the "~/Downloads" folder.

3. Extract Go in your home directory
$cd ~
$tar zxvf ~/Downloads/go1.0.3.linux-amd64.tar.gz
4. Add the Go binaries to the path.
$gedit ~/.bashrc
Add the following lines
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
Reload the shell environment
$source ~/.bashrc
5. Check if Go is available
Go is a tool for managing Go source code.
 go command [arguments]
The commands are:...
Good !

6. Now to build llgo we are going to use "go get" command. These steps are also listed in the llgo's README.md file on their website https://github.com/axw/llgo. Type the following in the shell
$export CGO_CFLAGS="`llvm-config --cflags`"
$export CGO_LDFLAGS="`llvm-config --ldflags` -Wl,-L`llvm-config --libdir` -lLLVM-`llvm-config --version`"
$go get github.com/axw/llgo/llgo
It will automatically build and install the llgo binaries in the "~/go/bin" folder.

7. Check if the "llgo" has been build
$ls ~/go/bin
go  godoc  gofmt  llgo
No Go source files were specified
There it is :)

8. Lets test it
$gedit ~/test.go
Add these lines
package main
import "fmt"
func main() {
  fmt.Println("Hello World")
Now run on the terminal
$llgo -dump test.go

; ModuleID = 'main'
target datalayout = "e-p:64:64:64..."
target triple = "x86_64-unknown-linux"
%0 = type { i8*, i8* }
That's the LLVM assembly code which is then given to LLVM backend to generate the actual code.