devmapper: add useful comments

Upstream-commit: ad968ef3ef54f3161e8e1012f0ef20b8757ac0aa
Component: engine
This commit is contained in:
Solomon Hykes
2013-10-17 01:42:05 +00:00
parent 1dde114e36
commit 0563e530aa
2 changed files with 6 additions and 0 deletions

View File

@ -88,6 +88,10 @@ func (devices *DeviceSetDM) hasImage(name string) bool {
return err == nil
}
// ensureImage creates a sparse file of <size> bytes at the path
// <root>/devicemapper/<name>.
// If the file already exists, it does nothing.
// Either way it returns the full path.
func (devices *DeviceSetDM) ensureImage(name string, size int64) (string, error) {
dirname := devices.loopbackDir()
filename := path.Join(dirname, name)

View File

@ -18,6 +18,7 @@ package devmapper
#define LOOP_CTL_GET_FREE 0x4C82
#endif
// FIXME: this could easily be rewritten in go
char* attach_loop_device(const char *filename, int *loop_fd_out)
{
struct loop_info64 loopinfo = {0};
@ -441,6 +442,7 @@ func free(p *C.char) {
C.free(unsafe.Pointer(p))
}
// This is the programmatic example of "dmsetup create"
func createPool(poolName string, dataFile *os.File, metadataFile *os.File) error {
task, err := createTask(DeviceCreate, poolName)
if task == nil {