示例#1
0
// ListSelfManagedSnapshots returns a list of all self managed snapshots.
func (pool *Pool) ListPoolSnapshots() []SnapshotId {
	snaps := make([]SnapshotId, 0)
	for {
		var addr *C.rados_snap_t
		if len(snaps) > 0 {
			addr = (*C.rados_snap_t)(&snaps[0])
		}
		ret := C.rados_ioctx_snap_list(pool.context, addr, C.int(len(snaps)))
		if int(ret) == -int(syscall.ERANGE) {
			snaps = make([]SnapshotId, C.int(len(snaps))+1)
			continue
		}
		return snaps
	}
}
示例#2
0
func (r *RadosIoCtx) SnapList() ([]RadosSnapId, error) {
	var snap [MAX_SNAP_LEN]C.rados_snap_t
	cerr := C.rados_ioctx_snap_list(*r.ctx, &snap[0], MAX_SNAP_LEN)
	if cerr < 0 {
		return nil, errors.New("list snap failed")
	}

	if cerr > 0 {
		buf := make([]RadosSnapId, cerr)

		for k, _ := range snap {
			buf[k] = RadosSnapId(snap[k])
		}
		return buf, nil
	}
	return []RadosSnapId{}, nil
}