. if ${MACHINE_ARCH} == “i386”
. if ${CPUTYPE} == “nocona”
CPUTYPE = prescott

[base] View of /release/8.1.0/share/mk/bsd.cpu.mk

因此,如果你的 Atom 是 i386,那麼 march=nocona 會等於 march=prescott。


1 year ago
Intel, Atom, FreeBSD, nocona, prescott, CPU,

自發自轉,現在 GAISQ 上面也編好了,開發 php 會方便多囉!


1 year ago
FreeBSD, PHP, CLI, readline, bug, ports,

從 FreeBSD 7.0 開始,出現了 src.conf,讓你控制在 /usr/src 裡面要或不要編進去哪些東西,例如:html, doc, info, ppp, floppy, wireless…

之後跑 make delete-old 的時候,他還會把你原本有的 binary 殺掉。


1 year ago
FreeBSD,

FreeBSD mount_nfs memo

之前記過 FreeBSD nfsd 的服務流程,這邊記得是 FreeBSD mount_nfs 的流程:

  • mount_nfs 自己會先以 RPC 的 NFS_NULL_PROC 探看 server 的 nfsd
  • mount_nfs 接著以 RPC 的 RPC_MOUNT 對 server 的 mountd 取得 exported root handle。
  • mount_nfs 將取得的資訊以 iovec 的結構存起來。
  • mount_nfs 最後將這個 iovec 的參數丟進 nmount() system call 進入 kernel mode。
  • nmount() 訂義在 /usr/src/sys/kern/vfs_mount.c
  • nmount() 透過 vfs_domount() 呼叫到真正的 VFS_MOUNT()
  • 這時候就會由訂義在 /usr/src/sys/fs/nfsclient/nfs_clvfsops.cnfs_mount() 做真正的後續。
  • 在 kernel 的 vnode operations 裡,每當 mount 動作執行後,就會跟著執行 statfs。
  • 在 nfs 下,nfs_mount() 做完,就會跟著 nfs_statfs()
  • nfs_statfs() 裡面,會依序呼叫 FSINFOFSSTAT 這兩個 RPC procedure。

所以,這就是為什麼每當 client 做了 mount_nfs 以後,server 那邊收到的記錄是:NULL、FSINFO、FSSTAT。

1 year ago
FreeBSD, NFS, Programming, Memo,

FreeBSD ports 反安裝裝到一半的套件

如果你編某個 ports 已經編到一半了,回來看才發現它開始編 X 了,忘了加 WITHOUT_X11 或是 make config:

  • Ctrl-C 中斷現在編的程序
  • 到那個 ports 的目錄
  • make all-depends-list | awk -F '/' '{print $5}' | xargs pkg_deinstall

好早以前發現的,每次都忘記…

1 year ago
FreeBSD, ports,

Becoming a FreeBSD kernel newbie!


1 year ago
FreeBSD, namei, kernel,

FreeBSD nfsserver.ko - nfsrv_read()

nfsrv_read() 這個函式負責負作 NFS 收到的 read procedure。

首先它會從 request decode 取得 file handle,offset 與 count,根據 offset 與 count 總合的大小建立一「串」mbuf。然後將這串 mbuf 分別指派給 struct uio 的 io vector(struct iovec :[vec_base, vec_len])。

最後執行 VOP_READ() 這個神祕的函式將 file handle 在 offset 到 count 的資料,讀到 io vector 中,也就是讀到 mbuf 中。

再由 kernel 將 mbuf 們傳到網路上。

1 year ago
freebsd, nfs,

FreeBSD nfsserver.ko - overview

這裡先筆記一下 FreeBSD nfsserver kernel module 的實作 overview。

  • nfsd 收到 rpc request 後,會透過 nfssvc() 進入 kernel mode,然後 nfsserver.ko 會接手處理。
  • nfsserver.ko 中的 nfs_srvkrpc.c 實作 nfssvc_program(),負責 recv、decode、exec procedure、response NFS rpc request,是主要的 controller。
  • nfssvc_program() 會「準備一條 reply 用的 mbuf」,連同「RPC request 的 mbuf」,一起傳入給 proc() 去真正 execution。
  • proc 是 function pointer,包括的函式都被寫在 nfs_serv.c。
  • 這些函式會提取 request mbuf,做相應的操作,寫在 reply 的 mbuf(所在的 address)。
  • 這些函式執行完,會返回 nfssvc_program()。
  • nfssvc_program() 將已經被寫入的「reply 用 mbuf」重新 encode 並且送回去給 client。
1 year ago
freebsd, nfsserver, kernel,

The Design and Implementation of the FreeBSD Operating System - aNobii

從來都沒想過在 2004 年買的書,現在非常有用。
從來也沒想過我會投入改 FreeBSD NFS 下層。
因為老師的 CloudBase 計畫讓外界可以透過 NFS 取得 Cloud 中的資料。
這本書就算過了 6 年,還是非常實用!


1 year ago
FreeBSD,

FreeBSD php-5.3

20100409: AFFECTS: users of lang/php5 AUTHOR: ale@FreeBSD.org

    As of php 5.3, a few extensions were removed from or included into the core
    php5 package.  Follow the steps below to update your installation.

    1) Delete the following packages (if installed):
        - php5-dbase
        - php5-ncurses
        - php5-pcre
        - php5-spl
        - php5-ming
        - php5-mhash

    2) Rebuild php5 and all ports depending on it.
1 year ago
FreeBSD, php, ports,

FreeBSD ZFS 小使用感想

雖然一出來的時候就讓 Lab 的 Server 用 ZFS 了,但直到今天我才真正去「管理」ZFS。

  • 跑 zpool status -v 發現有兩個 file corruption 的 error,我選擇直接 rm 掉它們,然後執行 zdb,接著要使用「zpool clear」把 error log 清掉。
  • 再跑一次 zpool status -v,它變成說「你的 pool 是過時的版本,現在用的是 14」,所以要我做「zpool upgrade -a」把原本 version 13 pool 升級成 version 14 pool。
  • 最後再跑一次 zpool status,就沒有任何靠要訊息了。

對於可以直接升級 pool,這想法還蠻酷的,一個活著的檔案系統。

雖然只用了這兩個小功能,就開始能夠感覺到 ZFS 對於管理的方便性。

1 year ago
FreeBSD, ZFS, File System,