id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,300 | containers/storage | drivers/windows/windows.go | UpdateLayerIDMap | func (d *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMappings, mountLabel string) error {
return fmt.Errorf("windows doesn't support changing ID mappings")
} | go | func (d *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMappings, mountLabel string) error {
return fmt.Errorf("windows doesn't support changing ID mappings")
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"UpdateLayerIDMap",
"(",
"id",
"string",
",",
"toContainer",
",",
"toHost",
"*",
"idtools",
".",
"IDMappings",
",",
"mountLabel",
"string",
")",
"error",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"... | // UpdateLayerIDMap changes ownerships in the layer's filesystem tree from
// matching those in toContainer to matching those in toHost. | [
"UpdateLayerIDMap",
"changes",
"ownerships",
"in",
"the",
"layer",
"s",
"filesystem",
"tree",
"from",
"matching",
"those",
"in",
"toContainer",
"to",
"matching",
"those",
"in",
"toHost",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/windows/windows.go#L961-L963 |
141,301 | containers/storage | drivers/devmapper/deviceset.go | cleanupDeletedDevices | func (devices *DeviceSet) cleanupDeletedDevices() error {
devices.Lock()
// If there are no deleted devices, there is nothing to do.
if devices.nrDeletedDevices == 0 {
devices.Unlock()
return nil
}
var deletedDevices []*devInfo
for _, info := range devices.Devices {
if !info.Deleted {
continue
}
l... | go | func (devices *DeviceSet) cleanupDeletedDevices() error {
devices.Lock()
// If there are no deleted devices, there is nothing to do.
if devices.nrDeletedDevices == 0 {
devices.Unlock()
return nil
}
var deletedDevices []*devInfo
for _, info := range devices.Devices {
if !info.Deleted {
continue
}
l... | [
"func",
"(",
"devices",
"*",
"DeviceSet",
")",
"cleanupDeletedDevices",
"(",
")",
"error",
"{",
"devices",
".",
"Lock",
"(",
")",
"\n\n",
"// If there are no deleted devices, there is nothing to do.",
"if",
"devices",
".",
"nrDeletedDevices",
"==",
"0",
"{",
"device... | // Cleanup deleted devices. It assumes that all the devices have been
// loaded in the hash table. | [
"Cleanup",
"deleted",
"devices",
".",
"It",
"assumes",
"that",
"all",
"the",
"devices",
"have",
"been",
"loaded",
"in",
"the",
"hash",
"table",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/devmapper/deviceset.go#L658-L689 |
141,302 | containers/storage | drivers/devmapper/deviceset.go | thinPoolExists | func (devices *DeviceSet) thinPoolExists(thinPoolDevice string) (bool, error) {
logrus.Debugf("devmapper: Checking for existence of the pool %s", thinPoolDevice)
info, err := devicemapper.GetInfo(thinPoolDevice)
if err != nil {
return false, fmt.Errorf("devmapper: GetInfo() on device %s failed: %v", thinPoolDevic... | go | func (devices *DeviceSet) thinPoolExists(thinPoolDevice string) (bool, error) {
logrus.Debugf("devmapper: Checking for existence of the pool %s", thinPoolDevice)
info, err := devicemapper.GetInfo(thinPoolDevice)
if err != nil {
return false, fmt.Errorf("devmapper: GetInfo() on device %s failed: %v", thinPoolDevic... | [
"func",
"(",
"devices",
"*",
"DeviceSet",
")",
"thinPoolExists",
"(",
"thinPoolDevice",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"thinPoolDevice",
")",
"\n\n",
"info",
",",
"err",
":=",
"devicemap... | // Returns if thin pool device exists or not. If device exists, also makes
// sure it is a thin pool device and not some other type of device. | [
"Returns",
"if",
"thin",
"pool",
"device",
"exists",
"or",
"not",
".",
"If",
"device",
"exists",
"also",
"makes",
"sure",
"it",
"is",
"a",
"thin",
"pool",
"device",
"and",
"not",
"some",
"other",
"type",
"of",
"device",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/devmapper/deviceset.go#L1094-L1117 |
141,303 | containers/storage | drivers/devmapper/deviceset.go | getDeviceMajorMinor | func getDeviceMajorMinor(file *os.File) (uint64, uint64, error) {
var stat unix.Stat_t
err := unix.Stat(file.Name(), &stat)
if err != nil {
return 0, 0, err
}
dev := stat.Rdev
majorNum := major(dev)
minorNum := minor(dev)
logrus.Debugf("devmapper: Major:Minor for device: %s is:%v:%v", file.Name(), majorNum,... | go | func getDeviceMajorMinor(file *os.File) (uint64, uint64, error) {
var stat unix.Stat_t
err := unix.Stat(file.Name(), &stat)
if err != nil {
return 0, 0, err
}
dev := stat.Rdev
majorNum := major(dev)
minorNum := minor(dev)
logrus.Debugf("devmapper: Major:Minor for device: %s is:%v:%v", file.Name(), majorNum,... | [
"func",
"getDeviceMajorMinor",
"(",
"file",
"*",
"os",
".",
"File",
")",
"(",
"uint64",
",",
"uint64",
",",
"error",
")",
"{",
"var",
"stat",
"unix",
".",
"Stat_t",
"\n",
"err",
":=",
"unix",
".",
"Stat",
"(",
"file",
".",
"Name",
"(",
")",
",",
... | // Determine the major and minor number of loopback device | [
"Determine",
"the",
"major",
"and",
"minor",
"number",
"of",
"loopback",
"device"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/devmapper/deviceset.go#L1534-L1547 |
141,304 | containers/storage | drivers/devmapper/deviceset.go | issueDiscard | func (devices *DeviceSet) issueDiscard(info *devInfo) error {
logrus.Debugf("devmapper: issueDiscard START(device: %s).", info.Hash)
defer logrus.Debugf("devmapper: issueDiscard END(device: %s).", info.Hash)
// This is a workaround for the kernel not discarding block so
// on the thin pool when we remove a thinp de... | go | func (devices *DeviceSet) issueDiscard(info *devInfo) error {
logrus.Debugf("devmapper: issueDiscard START(device: %s).", info.Hash)
defer logrus.Debugf("devmapper: issueDiscard END(device: %s).", info.Hash)
// This is a workaround for the kernel not discarding block so
// on the thin pool when we remove a thinp de... | [
"func",
"(",
"devices",
"*",
"DeviceSet",
")",
"issueDiscard",
"(",
"info",
"*",
"devInfo",
")",
"error",
"{",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"info",
".",
"Hash",
")",
"\n",
"defer",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"i... | // Issue discard only if device open count is zero. | [
"Issue",
"discard",
"only",
"if",
"device",
"open",
"count",
"is",
"zero",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/devmapper/deviceset.go#L2044-L2070 |
141,305 | containers/storage | store.go | GetDigestLock | func (s *store) GetDigestLock(d digest.Digest) (Locker, error) {
return GetLockfile(filepath.Join(s.digestLockRoot, d.String()))
} | go | func (s *store) GetDigestLock(d digest.Digest) (Locker, error) {
return GetLockfile(filepath.Join(s.digestLockRoot, d.String()))
} | [
"func",
"(",
"s",
"*",
"store",
")",
"GetDigestLock",
"(",
"d",
"digest",
".",
"Digest",
")",
"(",
"Locker",
",",
"error",
")",
"{",
"return",
"GetLockfile",
"(",
"filepath",
".",
"Join",
"(",
"s",
".",
"digestLockRoot",
",",
"d",
".",
"String",
"(",... | // GetDigestLock returns a digest-specific Locker. | [
"GetDigestLock",
"returns",
"a",
"digest",
"-",
"specific",
"Locker",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/store.go#L715-L717 |
141,306 | containers/storage | store.go | LayerStore | func (s *store) LayerStore() (LayerStore, error) {
s.graphLock.Lock()
defer s.graphLock.Unlock()
if s.graphLock.TouchedSince(s.lastLoaded) {
s.graphDriver = nil
s.layerStore = nil
s.lastLoaded = time.Now()
}
if s.layerStore != nil {
return s.layerStore, nil
}
driver, err := s.getGraphDriver()
if err != ... | go | func (s *store) LayerStore() (LayerStore, error) {
s.graphLock.Lock()
defer s.graphLock.Unlock()
if s.graphLock.TouchedSince(s.lastLoaded) {
s.graphDriver = nil
s.layerStore = nil
s.lastLoaded = time.Now()
}
if s.layerStore != nil {
return s.layerStore, nil
}
driver, err := s.getGraphDriver()
if err != ... | [
"func",
"(",
"s",
"*",
"store",
")",
"LayerStore",
"(",
")",
"(",
"LayerStore",
",",
"error",
")",
"{",
"s",
".",
"graphLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"graphLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"s",
".",
"graphLock"... | // LayerStore obtains and returns a handle to the writeable layer store object
// used by the Store. Accessing this store directly will bypass locking and
// synchronization, so it is not a part of the exported Store interface. | [
"LayerStore",
"obtains",
"and",
"returns",
"a",
"handle",
"to",
"the",
"writeable",
"layer",
"store",
"object",
"used",
"by",
"the",
"Store",
".",
"Accessing",
"this",
"store",
"directly",
"will",
"bypass",
"locking",
"and",
"synchronization",
"so",
"it",
"is"... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/store.go#L752-L782 |
141,307 | containers/storage | store.go | ImageStore | func (s *store) ImageStore() (ImageStore, error) {
if s.imageStore != nil {
return s.imageStore, nil
}
return nil, ErrLoadError
} | go | func (s *store) ImageStore() (ImageStore, error) {
if s.imageStore != nil {
return s.imageStore, nil
}
return nil, ErrLoadError
} | [
"func",
"(",
"s",
"*",
"store",
")",
"ImageStore",
"(",
")",
"(",
"ImageStore",
",",
"error",
")",
"{",
"if",
"s",
".",
"imageStore",
"!=",
"nil",
"{",
"return",
"s",
".",
"imageStore",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"ErrLoadErr... | // ImageStore obtains and returns a handle to the writable image store object
// used by the Store. Accessing this store directly will bypass locking and
// synchronization, so it is not a part of the exported Store interface. | [
"ImageStore",
"obtains",
"and",
"returns",
"a",
"handle",
"to",
"the",
"writable",
"image",
"store",
"object",
"used",
"by",
"the",
"Store",
".",
"Accessing",
"this",
"store",
"directly",
"will",
"bypass",
"locking",
"and",
"synchronization",
"so",
"it",
"is",... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/store.go#L816-L821 |
141,308 | containers/storage | store.go | ContainerStore | func (s *store) ContainerStore() (ContainerStore, error) {
if s.containerStore != nil {
return s.containerStore, nil
}
return nil, ErrLoadError
} | go | func (s *store) ContainerStore() (ContainerStore, error) {
if s.containerStore != nil {
return s.containerStore, nil
}
return nil, ErrLoadError
} | [
"func",
"(",
"s",
"*",
"store",
")",
"ContainerStore",
"(",
")",
"(",
"ContainerStore",
",",
"error",
")",
"{",
"if",
"s",
".",
"containerStore",
"!=",
"nil",
"{",
"return",
"s",
".",
"containerStore",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",... | // ContainerStore obtains and returns a handle to the container store object
// used by the Store. Accessing this store directly will bypass locking and
// synchronization, so it is not a part of the exported Store interface. | [
"ContainerStore",
"obtains",
"and",
"returns",
"a",
"handle",
"to",
"the",
"container",
"store",
"object",
"used",
"by",
"the",
"Store",
".",
"Accessing",
"this",
"store",
"directly",
"will",
"bypass",
"locking",
"and",
"synchronization",
"so",
"it",
"is",
"no... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/store.go#L849-L854 |
141,309 | containers/storage | store.go | makeBigDataBaseName | func makeBigDataBaseName(key string) string {
reader := strings.NewReader(key)
for reader.Len() > 0 {
ch, size, err := reader.ReadRune()
if err != nil || size != 1 {
break
}
if ch != '.' && !(ch >= '0' && ch <= '9') && !(ch >= 'a' && ch <= 'z') {
break
}
}
if reader.Len() > 0 {
return "=" + base64... | go | func makeBigDataBaseName(key string) string {
reader := strings.NewReader(key)
for reader.Len() > 0 {
ch, size, err := reader.ReadRune()
if err != nil || size != 1 {
break
}
if ch != '.' && !(ch >= '0' && ch <= '9') && !(ch >= 'a' && ch <= 'z') {
break
}
}
if reader.Len() > 0 {
return "=" + base64... | [
"func",
"makeBigDataBaseName",
"(",
"key",
"string",
")",
"string",
"{",
"reader",
":=",
"strings",
".",
"NewReader",
"(",
"key",
")",
"\n",
"for",
"reader",
".",
"Len",
"(",
")",
">",
"0",
"{",
"ch",
",",
"size",
",",
"err",
":=",
"reader",
".",
"... | // Convert a BigData key name into an acceptable file name. | [
"Convert",
"a",
"BigData",
"key",
"name",
"into",
"an",
"acceptable",
"file",
"name",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/store.go#L3167-L3182 |
141,310 | containers/storage | store.go | DefaultConfigFile | func DefaultConfigFile(rootless bool) (string, error) {
if rootless {
home, err := homeDir()
if err != nil {
return "", errors.Wrapf(err, "cannot determine users homedir")
}
return filepath.Join(home, ".config/containers/storage.conf"), nil
}
return defaultConfigFile, nil
} | go | func DefaultConfigFile(rootless bool) (string, error) {
if rootless {
home, err := homeDir()
if err != nil {
return "", errors.Wrapf(err, "cannot determine users homedir")
}
return filepath.Join(home, ".config/containers/storage.conf"), nil
}
return defaultConfigFile, nil
} | [
"func",
"DefaultConfigFile",
"(",
"rootless",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"rootless",
"{",
"home",
",",
"err",
":=",
"homeDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"... | // DefaultConfigFile returns the path to the storage config file used | [
"DefaultConfigFile",
"returns",
"the",
"path",
"to",
"the",
"storage",
"config",
"file",
"used"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/store.go#L3243-L3252 |
141,311 | containers/storage | pkg/archive/changes_linux.go | walkchunk | func walkchunk(path string, fi os.FileInfo, dir string, root *FileInfo) error {
if fi == nil {
return nil
}
parent := root.LookUp(filepath.Dir(path))
if parent == nil {
return fmt.Errorf("walkchunk: Unexpectedly no parent for %s", path)
}
info := &FileInfo{
name: filepath.Base(path),
children: mak... | go | func walkchunk(path string, fi os.FileInfo, dir string, root *FileInfo) error {
if fi == nil {
return nil
}
parent := root.LookUp(filepath.Dir(path))
if parent == nil {
return fmt.Errorf("walkchunk: Unexpectedly no parent for %s", path)
}
info := &FileInfo{
name: filepath.Base(path),
children: mak... | [
"func",
"walkchunk",
"(",
"path",
"string",
",",
"fi",
"os",
".",
"FileInfo",
",",
"dir",
"string",
",",
"root",
"*",
"FileInfo",
")",
"error",
"{",
"if",
"fi",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"parent",
":=",
"root",
".",
"LookU... | // Given a FileInfo, its path info, and a reference to the root of the tree
// being constructed, register this file with the tree. | [
"Given",
"a",
"FileInfo",
"its",
"path",
"info",
"and",
"a",
"reference",
"to",
"the",
"root",
"of",
"the",
"tree",
"being",
"constructed",
"register",
"this",
"file",
"with",
"the",
"tree",
"."
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/changes_linux.go#L66-L89 |
141,312 | containers/storage | pkg/archive/diff.go | ApplyLayer | func ApplyLayer(dest string, layer io.Reader) (int64, error) {
return applyLayerHandler(dest, layer, &TarOptions{}, true)
} | go | func ApplyLayer(dest string, layer io.Reader) (int64, error) {
return applyLayerHandler(dest, layer, &TarOptions{}, true)
} | [
"func",
"ApplyLayer",
"(",
"dest",
"string",
",",
"layer",
"io",
".",
"Reader",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"applyLayerHandler",
"(",
"dest",
",",
"layer",
",",
"&",
"TarOptions",
"{",
"}",
",",
"true",
")",
"\n",
"}"
] | // ApplyLayer parses a diff in the standard layer format from `layer`,
// and applies it to the directory `dest`. The stream `layer` can be
// compressed or uncompressed.
// Returns the size in bytes of the contents of the layer. | [
"ApplyLayer",
"parses",
"a",
"diff",
"in",
"the",
"standard",
"layer",
"format",
"from",
"layer",
"and",
"applies",
"it",
"to",
"the",
"directory",
"dest",
".",
"The",
"stream",
"layer",
"can",
"be",
"compressed",
"or",
"uncompressed",
".",
"Returns",
"the",... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/diff.go#L226-L228 |
141,313 | containers/storage | pkg/archive/diff.go | applyLayerHandler | func applyLayerHandler(dest string, layer io.Reader, options *TarOptions, decompress bool) (int64, error) {
dest = filepath.Clean(dest)
// We need to be able to set any perms
oldmask, err := system.Umask(0)
if err != nil {
return 0, err
}
defer system.Umask(oldmask) // ignore err, ErrNotSupportedPlatform
if ... | go | func applyLayerHandler(dest string, layer io.Reader, options *TarOptions, decompress bool) (int64, error) {
dest = filepath.Clean(dest)
// We need to be able to set any perms
oldmask, err := system.Umask(0)
if err != nil {
return 0, err
}
defer system.Umask(oldmask) // ignore err, ErrNotSupportedPlatform
if ... | [
"func",
"applyLayerHandler",
"(",
"dest",
"string",
",",
"layer",
"io",
".",
"Reader",
",",
"options",
"*",
"TarOptions",
",",
"decompress",
"bool",
")",
"(",
"int64",
",",
"error",
")",
"{",
"dest",
"=",
"filepath",
".",
"Clean",
"(",
"dest",
")",
"\n... | // do the bulk load of ApplyLayer, but allow for not calling DecompressStream | [
"do",
"the",
"bulk",
"load",
"of",
"ApplyLayer",
"but",
"allow",
"for",
"not",
"calling",
"DecompressStream"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/diff.go#L239-L256 |
141,314 | containers/storage | drivers/chown.go | ChownPathByMaps | func ChownPathByMaps(path string, toContainer, toHost *idtools.IDMappings) error {
if toContainer == nil {
toContainer = &idtools.IDMappings{}
}
if toHost == nil {
toHost = &idtools.IDMappings{}
}
config, err := json.Marshal([4][]idtools.IDMap{toContainer.UIDs(), toContainer.GIDs(), toHost.UIDs(), toHost.GIDs... | go | func ChownPathByMaps(path string, toContainer, toHost *idtools.IDMappings) error {
if toContainer == nil {
toContainer = &idtools.IDMappings{}
}
if toHost == nil {
toHost = &idtools.IDMappings{}
}
config, err := json.Marshal([4][]idtools.IDMap{toContainer.UIDs(), toContainer.GIDs(), toHost.UIDs(), toHost.GIDs... | [
"func",
"ChownPathByMaps",
"(",
"path",
"string",
",",
"toContainer",
",",
"toHost",
"*",
"idtools",
".",
"IDMappings",
")",
"error",
"{",
"if",
"toContainer",
"==",
"nil",
"{",
"toContainer",
"=",
"&",
"idtools",
".",
"IDMappings",
"{",
"}",
"\n",
"}",
... | // ChownPathByMaps walks the filesystem tree, changing the ownership
// information using the toContainer and toHost mappings, using them to replace
// on-disk owner UIDs and GIDs which are "host" values in the first map with
// UIDs and GIDs for "host" values from the second map which correspond to the
// same "contai... | [
"ChownPathByMaps",
"walks",
"the",
"filesystem",
"tree",
"changing",
"the",
"ownership",
"information",
"using",
"the",
"toContainer",
"and",
"toHost",
"mappings",
"using",
"them",
"to",
"replace",
"on",
"-",
"disk",
"owner",
"UIDs",
"and",
"GIDs",
"which",
"are... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/chown.go#L72-L98 |
141,315 | containers/storage | drivers/chown.go | UpdateLayerIDMap | func (n *naiveLayerIDMapUpdater) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMappings, mountLabel string) error {
driver := n.ProtoDriver
options := MountOpts{
MountLabel: mountLabel,
}
layerFs, err := driver.Get(id, options)
if err != nil {
return err
}
defer func() {
driver.Put(id)
}()
... | go | func (n *naiveLayerIDMapUpdater) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMappings, mountLabel string) error {
driver := n.ProtoDriver
options := MountOpts{
MountLabel: mountLabel,
}
layerFs, err := driver.Get(id, options)
if err != nil {
return err
}
defer func() {
driver.Put(id)
}()
... | [
"func",
"(",
"n",
"*",
"naiveLayerIDMapUpdater",
")",
"UpdateLayerIDMap",
"(",
"id",
"string",
",",
"toContainer",
",",
"toHost",
"*",
"idtools",
".",
"IDMappings",
",",
"mountLabel",
"string",
")",
"error",
"{",
"driver",
":=",
"n",
".",
"ProtoDriver",
"\n"... | // UpdateLayerIDMap walks the layer's filesystem tree, changing the ownership
// information using the toContainer and toHost mappings, using them to replace
// on-disk owner UIDs and GIDs which are "host" values in the first map with
// UIDs and GIDs for "host" values from the second map which correspond to the
// sam... | [
"UpdateLayerIDMap",
"walks",
"the",
"layer",
"s",
"filesystem",
"tree",
"changing",
"the",
"ownership",
"information",
"using",
"the",
"toContainer",
"and",
"toHost",
"mappings",
"using",
"them",
"to",
"replace",
"on",
"-",
"disk",
"owner",
"UIDs",
"and",
"GIDs"... | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/chown.go#L115-L129 |
141,316 | containers/storage | drivers/copy/copy_unsupported.go | DirCopy | func DirCopy(srcDir, dstDir string, _ Mode, _ bool) error {
return chrootarchive.NewArchiver(nil).CopyWithTar(srcDir, dstDir)
} | go | func DirCopy(srcDir, dstDir string, _ Mode, _ bool) error {
return chrootarchive.NewArchiver(nil).CopyWithTar(srcDir, dstDir)
} | [
"func",
"DirCopy",
"(",
"srcDir",
",",
"dstDir",
"string",
",",
"_",
"Mode",
",",
"_",
"bool",
")",
"error",
"{",
"return",
"chrootarchive",
".",
"NewArchiver",
"(",
"nil",
")",
".",
"CopyWithTar",
"(",
"srcDir",
",",
"dstDir",
")",
"\n",
"}"
] | // DirCopy copies or hardlinks the contents of one directory to another,
// properly handling soft links | [
"DirCopy",
"copies",
"or",
"hardlinks",
"the",
"contents",
"of",
"one",
"directory",
"to",
"another",
"properly",
"handling",
"soft",
"links"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/copy/copy_unsupported.go#L17-L19 |
141,317 | containers/storage | drivers/driver_solaris.go | Mounted | func Mounted(fsType FsMagic, mountPath string) (bool, error) {
cs := C.CString(filepath.Dir(mountPath))
defer C.free(unsafe.Pointer(cs))
buf := C.getstatfs(cs)
defer C.free(unsafe.Pointer(buf))
// on Solaris buf.f_basetype contains ['z', 'f', 's', 0 ... ]
if (buf.f_basetype[0] != 122) || (buf.f_basetype[1] != 1... | go | func Mounted(fsType FsMagic, mountPath string) (bool, error) {
cs := C.CString(filepath.Dir(mountPath))
defer C.free(unsafe.Pointer(cs))
buf := C.getstatfs(cs)
defer C.free(unsafe.Pointer(buf))
// on Solaris buf.f_basetype contains ['z', 'f', 's', 0 ... ]
if (buf.f_basetype[0] != 122) || (buf.f_basetype[1] != 1... | [
"func",
"Mounted",
"(",
"fsType",
"FsMagic",
",",
"mountPath",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"cs",
":=",
"C",
".",
"CString",
"(",
"filepath",
".",
"Dir",
"(",
"mountPath",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsa... | // Mounted checks if the given path is mounted as the fs type
//Solaris supports only ZFS for now | [
"Mounted",
"checks",
"if",
"the",
"given",
"path",
"is",
"mounted",
"as",
"the",
"fs",
"type",
"Solaris",
"supports",
"only",
"ZFS",
"for",
"now"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/drivers/driver_solaris.go#L81-L96 |
141,318 | containers/storage | lockfile_linux.go | TouchedSince | func (l *lockfile) TouchedSince(when time.Time) bool {
st := unix.Stat_t{}
err := unix.Fstat(int(l.fd), &st)
if err != nil {
return true
}
touched := time.Unix(st.Mtim.Unix())
return when.Before(touched)
} | go | func (l *lockfile) TouchedSince(when time.Time) bool {
st := unix.Stat_t{}
err := unix.Fstat(int(l.fd), &st)
if err != nil {
return true
}
touched := time.Unix(st.Mtim.Unix())
return when.Before(touched)
} | [
"func",
"(",
"l",
"*",
"lockfile",
")",
"TouchedSince",
"(",
"when",
"time",
".",
"Time",
")",
"bool",
"{",
"st",
":=",
"unix",
".",
"Stat_t",
"{",
"}",
"\n",
"err",
":=",
"unix",
".",
"Fstat",
"(",
"int",
"(",
"l",
".",
"fd",
")",
",",
"&",
... | // TouchedSince indicates if the lock file has been touched since the specified time | [
"TouchedSince",
"indicates",
"if",
"the",
"lock",
"file",
"has",
"been",
"touched",
"since",
"the",
"specified",
"time"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/lockfile_linux.go#L12-L20 |
141,319 | containers/storage | pkg/archive/archive.go | NewDefaultArchiver | func NewDefaultArchiver() *Archiver {
return &Archiver{Untar: Untar, TarIDMappings: &idtools.IDMappings{}, UntarIDMappings: &idtools.IDMappings{}}
} | go | func NewDefaultArchiver() *Archiver {
return &Archiver{Untar: Untar, TarIDMappings: &idtools.IDMappings{}, UntarIDMappings: &idtools.IDMappings{}}
} | [
"func",
"NewDefaultArchiver",
"(",
")",
"*",
"Archiver",
"{",
"return",
"&",
"Archiver",
"{",
"Untar",
":",
"Untar",
",",
"TarIDMappings",
":",
"&",
"idtools",
".",
"IDMappings",
"{",
"}",
",",
"UntarIDMappings",
":",
"&",
"idtools",
".",
"IDMappings",
"{"... | // NewDefaultArchiver returns a new Archiver without any IDMappings | [
"NewDefaultArchiver",
"returns",
"a",
"new",
"Archiver",
"without",
"any",
"IDMappings"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/archive.go#L83-L85 |
141,320 | containers/storage | pkg/archive/archive.go | NewArchiver | func NewArchiver(idMappings *idtools.IDMappings) *Archiver {
if idMappings == nil {
idMappings = &idtools.IDMappings{}
}
return &Archiver{Untar: Untar, TarIDMappings: idMappings, UntarIDMappings: idMappings}
} | go | func NewArchiver(idMappings *idtools.IDMappings) *Archiver {
if idMappings == nil {
idMappings = &idtools.IDMappings{}
}
return &Archiver{Untar: Untar, TarIDMappings: idMappings, UntarIDMappings: idMappings}
} | [
"func",
"NewArchiver",
"(",
"idMappings",
"*",
"idtools",
".",
"IDMappings",
")",
"*",
"Archiver",
"{",
"if",
"idMappings",
"==",
"nil",
"{",
"idMappings",
"=",
"&",
"idtools",
".",
"IDMappings",
"{",
"}",
"\n",
"}",
"\n",
"return",
"&",
"Archiver",
"{",... | // NewArchiver returns a new Archiver | [
"NewArchiver",
"returns",
"a",
"new",
"Archiver"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/archive.go#L1338-L1343 |
141,321 | containers/storage | pkg/archive/archive.go | NewArchiverWithChown | func NewArchiverWithChown(tarIDMappings *idtools.IDMappings, chownOpts *idtools.IDPair, untarIDMappings *idtools.IDMappings) *Archiver {
if tarIDMappings == nil {
tarIDMappings = &idtools.IDMappings{}
}
if untarIDMappings == nil {
untarIDMappings = &idtools.IDMappings{}
}
return &Archiver{Untar: Untar, TarIDMa... | go | func NewArchiverWithChown(tarIDMappings *idtools.IDMappings, chownOpts *idtools.IDPair, untarIDMappings *idtools.IDMappings) *Archiver {
if tarIDMappings == nil {
tarIDMappings = &idtools.IDMappings{}
}
if untarIDMappings == nil {
untarIDMappings = &idtools.IDMappings{}
}
return &Archiver{Untar: Untar, TarIDMa... | [
"func",
"NewArchiverWithChown",
"(",
"tarIDMappings",
"*",
"idtools",
".",
"IDMappings",
",",
"chownOpts",
"*",
"idtools",
".",
"IDPair",
",",
"untarIDMappings",
"*",
"idtools",
".",
"IDMappings",
")",
"*",
"Archiver",
"{",
"if",
"tarIDMappings",
"==",
"nil",
... | // NewArchiverWithChown returns a new Archiver which uses Untar and the provided ID mapping configuration on both ends | [
"NewArchiverWithChown",
"returns",
"a",
"new",
"Archiver",
"which",
"uses",
"Untar",
"and",
"the",
"provided",
"ID",
"mapping",
"configuration",
"on",
"both",
"ends"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/archive.go#L1346-L1354 |
141,322 | containers/storage | pkg/archive/archive.go | TarPath | func TarPath(uidmap []idtools.IDMap, gidmap []idtools.IDMap) func(path string) (io.ReadCloser, error) {
tarMappings := idtools.NewIDMappingsFromMaps(uidmap, gidmap)
return func(path string) (io.ReadCloser, error) {
return TarWithOptions(path, &TarOptions{
Compression: Uncompressed,
UIDMaps: tarMappings.UI... | go | func TarPath(uidmap []idtools.IDMap, gidmap []idtools.IDMap) func(path string) (io.ReadCloser, error) {
tarMappings := idtools.NewIDMappingsFromMaps(uidmap, gidmap)
return func(path string) (io.ReadCloser, error) {
return TarWithOptions(path, &TarOptions{
Compression: Uncompressed,
UIDMaps: tarMappings.UI... | [
"func",
"TarPath",
"(",
"uidmap",
"[",
"]",
"idtools",
".",
"IDMap",
",",
"gidmap",
"[",
"]",
"idtools",
".",
"IDMap",
")",
"func",
"(",
"path",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"tarMappings",
":=",
"idtools",
".",... | // TarPath returns a function which creates an archive of a specified
// location in the container's filesystem, mapping permissions using the
// container's ID maps | [
"TarPath",
"returns",
"a",
"function",
"which",
"creates",
"an",
"archive",
"of",
"a",
"specified",
"location",
"in",
"the",
"container",
"s",
"filesystem",
"mapping",
"permissions",
"using",
"the",
"container",
"s",
"ID",
"maps"
] | 94f0324a5d0c063ffa4adb04361dc2f863b17e05 | https://github.com/containers/storage/blob/94f0324a5d0c063ffa4adb04361dc2f863b17e05/pkg/archive/archive.go#L1431-L1440 |
141,323 | Masterminds/semver | version.go | NewVersion | func NewVersion(v string) (*Version, error) {
m := versionRegex.FindStringSubmatch(v)
if m == nil {
return nil, ErrInvalidSemVer
}
sv := &Version{
metadata: m[8],
pre: m[5],
original: v,
}
var temp int64
temp, err := strconv.ParseInt(m[1], 10, 64)
if err != nil {
return nil, fmt.Errorf("Error p... | go | func NewVersion(v string) (*Version, error) {
m := versionRegex.FindStringSubmatch(v)
if m == nil {
return nil, ErrInvalidSemVer
}
sv := &Version{
metadata: m[8],
pre: m[5],
original: v,
}
var temp int64
temp, err := strconv.ParseInt(m[1], 10, 64)
if err != nil {
return nil, fmt.Errorf("Error p... | [
"func",
"NewVersion",
"(",
"v",
"string",
")",
"(",
"*",
"Version",
",",
"error",
")",
"{",
"m",
":=",
"versionRegex",
".",
"FindStringSubmatch",
"(",
"v",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrInvalidSemVer",
"\n",
"}",
"... | // NewVersion parses a given version and returns an instance of Version or
// an error if unable to parse the version. | [
"NewVersion",
"parses",
"a",
"given",
"version",
"and",
"returns",
"an",
"instance",
"of",
"Version",
"or",
"an",
"error",
"if",
"unable",
"to",
"parse",
"the",
"version",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L54-L94 |
141,324 | Masterminds/semver | version.go | MustParse | func MustParse(v string) *Version {
sv, err := NewVersion(v)
if err != nil {
panic(err)
}
return sv
} | go | func MustParse(v string) *Version {
sv, err := NewVersion(v)
if err != nil {
panic(err)
}
return sv
} | [
"func",
"MustParse",
"(",
"v",
"string",
")",
"*",
"Version",
"{",
"sv",
",",
"err",
":=",
"NewVersion",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"sv",
"\n",
"}"
] | // MustParse parses a given version and panics on error. | [
"MustParse",
"parses",
"a",
"given",
"version",
"and",
"panics",
"on",
"error",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L97-L103 |
141,325 | Masterminds/semver | version.go | originalVPrefix | func (v *Version) originalVPrefix() string {
// Note, only lowercase v is supported as a prefix by the parser.
if v.original != "" && v.original[:1] == "v" {
return v.original[:1]
}
return ""
} | go | func (v *Version) originalVPrefix() string {
// Note, only lowercase v is supported as a prefix by the parser.
if v.original != "" && v.original[:1] == "v" {
return v.original[:1]
}
return ""
} | [
"func",
"(",
"v",
"*",
"Version",
")",
"originalVPrefix",
"(",
")",
"string",
"{",
"// Note, only lowercase v is supported as a prefix by the parser.",
"if",
"v",
".",
"original",
"!=",
"\"",
"\"",
"&&",
"v",
".",
"original",
"[",
":",
"1",
"]",
"==",
"\"",
... | // originalVPrefix returns the original 'v' prefix if any. | [
"originalVPrefix",
"returns",
"the",
"original",
"v",
"prefix",
"if",
"any",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L155-L162 |
141,326 | Masterminds/semver | version.go | IncMinor | func (v Version) IncMinor() Version {
vNext := v
vNext.metadata = ""
vNext.pre = ""
vNext.patch = 0
vNext.minor = v.minor + 1
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext
} | go | func (v Version) IncMinor() Version {
vNext := v
vNext.metadata = ""
vNext.pre = ""
vNext.patch = 0
vNext.minor = v.minor + 1
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext
} | [
"func",
"(",
"v",
"Version",
")",
"IncMinor",
"(",
")",
"Version",
"{",
"vNext",
":=",
"v",
"\n",
"vNext",
".",
"metadata",
"=",
"\"",
"\"",
"\n",
"vNext",
".",
"pre",
"=",
"\"",
"\"",
"\n",
"vNext",
".",
"patch",
"=",
"0",
"\n",
"vNext",
".",
... | // IncMinor produces the next minor version.
// Sets patch to 0.
// Increments minor number.
// Unsets metadata.
// Unsets prerelease status. | [
"IncMinor",
"produces",
"the",
"next",
"minor",
"version",
".",
"Sets",
"patch",
"to",
"0",
".",
"Increments",
"minor",
"number",
".",
"Unsets",
"metadata",
".",
"Unsets",
"prerelease",
"status",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L192-L200 |
141,327 | Masterminds/semver | version.go | IncMajor | func (v Version) IncMajor() Version {
vNext := v
vNext.metadata = ""
vNext.pre = ""
vNext.patch = 0
vNext.minor = 0
vNext.major = v.major + 1
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext
} | go | func (v Version) IncMajor() Version {
vNext := v
vNext.metadata = ""
vNext.pre = ""
vNext.patch = 0
vNext.minor = 0
vNext.major = v.major + 1
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext
} | [
"func",
"(",
"v",
"Version",
")",
"IncMajor",
"(",
")",
"Version",
"{",
"vNext",
":=",
"v",
"\n",
"vNext",
".",
"metadata",
"=",
"\"",
"\"",
"\n",
"vNext",
".",
"pre",
"=",
"\"",
"\"",
"\n",
"vNext",
".",
"patch",
"=",
"0",
"\n",
"vNext",
".",
... | // IncMajor produces the next major version.
// Sets patch to 0.
// Sets minor to 0.
// Increments major number.
// Unsets metadata.
// Unsets prerelease status. | [
"IncMajor",
"produces",
"the",
"next",
"major",
"version",
".",
"Sets",
"patch",
"to",
"0",
".",
"Sets",
"minor",
"to",
"0",
".",
"Increments",
"major",
"number",
".",
"Unsets",
"metadata",
".",
"Unsets",
"prerelease",
"status",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L208-L217 |
141,328 | Masterminds/semver | version.go | SetPrerelease | func (v Version) SetPrerelease(prerelease string) (Version, error) {
vNext := v
if len(prerelease) > 0 && !validPrereleaseRegex.MatchString(prerelease) {
return vNext, ErrInvalidPrerelease
}
vNext.pre = prerelease
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext, nil
} | go | func (v Version) SetPrerelease(prerelease string) (Version, error) {
vNext := v
if len(prerelease) > 0 && !validPrereleaseRegex.MatchString(prerelease) {
return vNext, ErrInvalidPrerelease
}
vNext.pre = prerelease
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext, nil
} | [
"func",
"(",
"v",
"Version",
")",
"SetPrerelease",
"(",
"prerelease",
"string",
")",
"(",
"Version",
",",
"error",
")",
"{",
"vNext",
":=",
"v",
"\n",
"if",
"len",
"(",
"prerelease",
")",
">",
"0",
"&&",
"!",
"validPrereleaseRegex",
".",
"MatchString",
... | // SetPrerelease defines the prerelease value.
// Value must not include the required 'hypen' prefix. | [
"SetPrerelease",
"defines",
"the",
"prerelease",
"value",
".",
"Value",
"must",
"not",
"include",
"the",
"required",
"hypen",
"prefix",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L221-L229 |
141,329 | Masterminds/semver | version.go | SetMetadata | func (v Version) SetMetadata(metadata string) (Version, error) {
vNext := v
if len(metadata) > 0 && !validPrereleaseRegex.MatchString(metadata) {
return vNext, ErrInvalidMetadata
}
vNext.metadata = metadata
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext, nil
} | go | func (v Version) SetMetadata(metadata string) (Version, error) {
vNext := v
if len(metadata) > 0 && !validPrereleaseRegex.MatchString(metadata) {
return vNext, ErrInvalidMetadata
}
vNext.metadata = metadata
vNext.original = v.originalVPrefix() + "" + vNext.String()
return vNext, nil
} | [
"func",
"(",
"v",
"Version",
")",
"SetMetadata",
"(",
"metadata",
"string",
")",
"(",
"Version",
",",
"error",
")",
"{",
"vNext",
":=",
"v",
"\n",
"if",
"len",
"(",
"metadata",
")",
">",
"0",
"&&",
"!",
"validPrereleaseRegex",
".",
"MatchString",
"(",
... | // SetMetadata defines metadata value.
// Value must not include the required 'plus' prefix. | [
"SetMetadata",
"defines",
"metadata",
"value",
".",
"Value",
"must",
"not",
"include",
"the",
"required",
"plus",
"prefix",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L233-L241 |
141,330 | Masterminds/semver | version.go | Compare | func (v *Version) Compare(o *Version) int {
// Compare the major, minor, and patch version for differences. If a
// difference is found return the comparison.
if d := compareSegment(v.Major(), o.Major()); d != 0 {
return d
}
if d := compareSegment(v.Minor(), o.Minor()); d != 0 {
return d
}
if d := compareSeg... | go | func (v *Version) Compare(o *Version) int {
// Compare the major, minor, and patch version for differences. If a
// difference is found return the comparison.
if d := compareSegment(v.Major(), o.Major()); d != 0 {
return d
}
if d := compareSegment(v.Minor(), o.Minor()); d != 0 {
return d
}
if d := compareSeg... | [
"func",
"(",
"v",
"*",
"Version",
")",
"Compare",
"(",
"o",
"*",
"Version",
")",
"int",
"{",
"// Compare the major, minor, and patch version for differences. If a",
"// difference is found return the comparison.",
"if",
"d",
":=",
"compareSegment",
"(",
"v",
".",
"Major... | // Compare compares this version to another one. It returns -1, 0, or 1 if
// the version smaller, equal, or larger than the other version.
//
// Versions are compared by X.Y.Z. Build metadata is ignored. Prerelease is
// lower than the version without a prerelease. | [
"Compare",
"compares",
"this",
"version",
"to",
"another",
"one",
".",
"It",
"returns",
"-",
"1",
"0",
"or",
"1",
"if",
"the",
"version",
"smaller",
"equal",
"or",
"larger",
"than",
"the",
"other",
"version",
".",
"Versions",
"are",
"compared",
"by",
"X"... | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L265-L293 |
141,331 | Masterminds/semver | version.go | UnmarshalJSON | func (v *Version) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
temp, err := NewVersion(s)
if err != nil {
return err
}
v.major = temp.major
v.minor = temp.minor
v.patch = temp.patch
v.pre = temp.pre
v.metadata = temp.metadata
v.original = temp.o... | go | func (v *Version) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
temp, err := NewVersion(s)
if err != nil {
return err
}
v.major = temp.major
v.minor = temp.minor
v.patch = temp.patch
v.pre = temp.pre
v.metadata = temp.metadata
v.original = temp.o... | [
"func",
"(",
"v",
"*",
"Version",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"s",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"return"... | // UnmarshalJSON implements JSON.Unmarshaler interface. | [
"UnmarshalJSON",
"implements",
"JSON",
".",
"Unmarshaler",
"interface",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/version.go#L296-L313 |
141,332 | Masterminds/semver | constraints.go | NewConstraint | func NewConstraint(c string) (*Constraints, error) {
// Rewrite - ranges into a comparison operation.
c = rewriteRange(c)
ors := strings.Split(c, "||")
or := make([][]*constraint, len(ors))
for k, v := range ors {
cs := strings.Split(v, ",")
result := make([]*constraint, len(cs))
for i, s := range cs {
... | go | func NewConstraint(c string) (*Constraints, error) {
// Rewrite - ranges into a comparison operation.
c = rewriteRange(c)
ors := strings.Split(c, "||")
or := make([][]*constraint, len(ors))
for k, v := range ors {
cs := strings.Split(v, ",")
result := make([]*constraint, len(cs))
for i, s := range cs {
... | [
"func",
"NewConstraint",
"(",
"c",
"string",
")",
"(",
"*",
"Constraints",
",",
"error",
")",
"{",
"// Rewrite - ranges into a comparison operation.",
"c",
"=",
"rewriteRange",
"(",
"c",
")",
"\n\n",
"ors",
":=",
"strings",
".",
"Split",
"(",
"c",
",",
"\"",... | // NewConstraint returns a Constraints instance that a Version instance can
// be checked against. If there is a parse error it will be returned. | [
"NewConstraint",
"returns",
"a",
"Constraints",
"instance",
"that",
"a",
"Version",
"instance",
"can",
"be",
"checked",
"against",
".",
"If",
"there",
"is",
"a",
"parse",
"error",
"it",
"will",
"be",
"returned",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/constraints.go#L18-L41 |
141,333 | Masterminds/semver | constraints.go | Check | func (cs Constraints) Check(v *Version) bool {
// loop over the ORs and check the inner ANDs
for _, o := range cs.constraints {
joy := true
for _, c := range o {
if !c.check(v) {
joy = false
break
}
}
if joy {
return true
}
}
return false
} | go | func (cs Constraints) Check(v *Version) bool {
// loop over the ORs and check the inner ANDs
for _, o := range cs.constraints {
joy := true
for _, c := range o {
if !c.check(v) {
joy = false
break
}
}
if joy {
return true
}
}
return false
} | [
"func",
"(",
"cs",
"Constraints",
")",
"Check",
"(",
"v",
"*",
"Version",
")",
"bool",
"{",
"// loop over the ORs and check the inner ANDs",
"for",
"_",
",",
"o",
":=",
"range",
"cs",
".",
"constraints",
"{",
"joy",
":=",
"true",
"\n",
"for",
"_",
",",
"... | // Check tests if a version satisfies the constraints. | [
"Check",
"tests",
"if",
"a",
"version",
"satisfies",
"the",
"constraints",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/constraints.go#L44-L61 |
141,334 | Masterminds/semver | constraints.go | Validate | func (cs Constraints) Validate(v *Version) (bool, []error) {
// loop over the ORs and check the inner ANDs
var e []error
for _, o := range cs.constraints {
joy := true
for _, c := range o {
if !c.check(v) {
em := fmt.Errorf(c.msg, v, c.orig)
e = append(e, em)
joy = false
}
}
if joy {
re... | go | func (cs Constraints) Validate(v *Version) (bool, []error) {
// loop over the ORs and check the inner ANDs
var e []error
for _, o := range cs.constraints {
joy := true
for _, c := range o {
if !c.check(v) {
em := fmt.Errorf(c.msg, v, c.orig)
e = append(e, em)
joy = false
}
}
if joy {
re... | [
"func",
"(",
"cs",
"Constraints",
")",
"Validate",
"(",
"v",
"*",
"Version",
")",
"(",
"bool",
",",
"[",
"]",
"error",
")",
"{",
"// loop over the ORs and check the inner ANDs",
"var",
"e",
"[",
"]",
"error",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
... | // Validate checks if a version satisfies a constraint. If not a slice of
// reasons for the failure are returned in addition to a bool. | [
"Validate",
"checks",
"if",
"a",
"version",
"satisfies",
"a",
"constraint",
".",
"If",
"not",
"a",
"slice",
"of",
"reasons",
"for",
"the",
"failure",
"are",
"returned",
"in",
"addition",
"to",
"a",
"bool",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/constraints.go#L65-L84 |
141,335 | Masterminds/semver | constraints.go | check | func (c *constraint) check(v *Version) bool {
return c.function(v, c)
} | go | func (c *constraint) check(v *Version) bool {
return c.function(v, c)
} | [
"func",
"(",
"c",
"*",
"constraint",
")",
"check",
"(",
"v",
"*",
"Version",
")",
"bool",
"{",
"return",
"c",
".",
"function",
"(",
"v",
",",
"c",
")",
"\n",
"}"
] | // Check if a version meets the constraint | [
"Check",
"if",
"a",
"version",
"meets",
"the",
"constraint"
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/constraints.go#L158-L160 |
141,336 | Masterminds/semver | collection.go | Less | func (c Collection) Less(i, j int) bool {
return c[i].LessThan(c[j])
} | go | func (c Collection) Less(i, j int) bool {
return c[i].LessThan(c[j])
} | [
"func",
"(",
"c",
"Collection",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"c",
"[",
"i",
"]",
".",
"LessThan",
"(",
"c",
"[",
"j",
"]",
")",
"\n",
"}"
] | // Less is needed for the sort interface to compare two Version objects on the
// slice. If checks if one is less than the other. | [
"Less",
"is",
"needed",
"for",
"the",
"sort",
"interface",
"to",
"compare",
"two",
"Version",
"objects",
"on",
"the",
"slice",
".",
"If",
"checks",
"if",
"one",
"is",
"less",
"than",
"the",
"other",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/collection.go#L16-L18 |
141,337 | Masterminds/semver | collection.go | Swap | func (c Collection) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
} | go | func (c Collection) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
} | [
"func",
"(",
"c",
"Collection",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"c",
"[",
"i",
"]",
",",
"c",
"[",
"j",
"]",
"=",
"c",
"[",
"j",
"]",
",",
"c",
"[",
"i",
"]",
"\n",
"}"
] | // Swap is needed for the sort interface to replace the Version objects
// at two different positions in the slice. | [
"Swap",
"is",
"needed",
"for",
"the",
"sort",
"interface",
"to",
"replace",
"the",
"Version",
"objects",
"at",
"two",
"different",
"positions",
"in",
"the",
"slice",
"."
] | 059deebd1619b9ae33232c797f7ab0e8d6c6fd69 | https://github.com/Masterminds/semver/blob/059deebd1619b9ae33232c797f7ab0e8d6c6fd69/collection.go#L22-L24 |
141,338 | mdlayher/netlink | debug.go | newDebugger | func newDebugger(args []string) *debugger {
d := &debugger{
Log: log.New(os.Stderr, "nl: ", 0),
Level: 1,
}
for _, a := range args {
kv := strings.Split(a, "=")
if len(kv) != 2 {
// Ignore malformed pairs and assume callers wants defaults.
continue
}
switch kv[0] {
// Select the log level for... | go | func newDebugger(args []string) *debugger {
d := &debugger{
Log: log.New(os.Stderr, "nl: ", 0),
Level: 1,
}
for _, a := range args {
kv := strings.Split(a, "=")
if len(kv) != 2 {
// Ignore malformed pairs and assume callers wants defaults.
continue
}
switch kv[0] {
// Select the log level for... | [
"func",
"newDebugger",
"(",
"args",
"[",
"]",
"string",
")",
"*",
"debugger",
"{",
"d",
":=",
"&",
"debugger",
"{",
"Log",
":",
"log",
".",
"New",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\"",
",",
"0",
")",
",",
"Level",
":",
"1",
",",
"}",
"\n... | // newDebugger creates a debugger by parsing key=value arguments. | [
"newDebugger",
"creates",
"a",
"debugger",
"by",
"parsing",
"key",
"=",
"value",
"arguments",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/debug.go#L31-L57 |
141,339 | mdlayher/netlink | debug.go | debugf | func (d *debugger) debugf(level int, format string, v ...interface{}) {
if d.Level >= level {
d.Log.Printf(format, v...)
}
} | go | func (d *debugger) debugf(level int, format string, v ...interface{}) {
if d.Level >= level {
d.Log.Printf(format, v...)
}
} | [
"func",
"(",
"d",
"*",
"debugger",
")",
"debugf",
"(",
"level",
"int",
",",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"d",
".",
"Level",
">=",
"level",
"{",
"d",
".",
"Log",
".",
"Printf",
"(",
"format",
",",
"... | // debugf prints debugging information at the specified level, if d.Level is
// high enough to print the message. | [
"debugf",
"prints",
"debugging",
"information",
"at",
"the",
"specified",
"level",
"if",
"d",
".",
"Level",
"is",
"high",
"enough",
"to",
"print",
"the",
"message",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/debug.go#L61-L65 |
141,340 | mdlayher/netlink | nlenc/int.go | PutUint8 | func PutUint8(b []byte, v uint8) {
if l := len(b); l != 1 {
panic(fmt.Sprintf("PutUint8: unexpected byte slice length: %d", l))
}
b[0] = v
} | go | func PutUint8(b []byte, v uint8) {
if l := len(b); l != 1 {
panic(fmt.Sprintf("PutUint8: unexpected byte slice length: %d", l))
}
b[0] = v
} | [
"func",
"PutUint8",
"(",
"b",
"[",
"]",
"byte",
",",
"v",
"uint8",
")",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"1",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"b"... | // PutUint8 encodes a uint8 into b.
// If b is not exactly 1 byte in length, PutUint8 will panic. | [
"PutUint8",
"encodes",
"a",
"uint8",
"into",
"b",
".",
"If",
"b",
"is",
"not",
"exactly",
"1",
"byte",
"in",
"length",
"PutUint8",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L10-L16 |
141,341 | mdlayher/netlink | nlenc/int.go | PutUint16 | func PutUint16(b []byte, v uint16) {
if l := len(b); l != 2 {
panic(fmt.Sprintf("PutUint16: unexpected byte slice length: %d", l))
}
*(*uint16)(unsafe.Pointer(&b[0])) = v
} | go | func PutUint16(b []byte, v uint16) {
if l := len(b); l != 2 {
panic(fmt.Sprintf("PutUint16: unexpected byte slice length: %d", l))
}
*(*uint16)(unsafe.Pointer(&b[0])) = v
} | [
"func",
"PutUint16",
"(",
"b",
"[",
"]",
"byte",
",",
"v",
"uint16",
")",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"2",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"... | // PutUint16 encodes a uint16 into b using the host machine's native endianness.
// If b is not exactly 2 bytes in length, PutUint16 will panic. | [
"PutUint16",
"encodes",
"a",
"uint16",
"into",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"2",
"bytes",
"in",
"length",
"PutUint16",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L20-L26 |
141,342 | mdlayher/netlink | nlenc/int.go | PutUint32 | func PutUint32(b []byte, v uint32) {
if l := len(b); l != 4 {
panic(fmt.Sprintf("PutUint32: unexpected byte slice length: %d", l))
}
*(*uint32)(unsafe.Pointer(&b[0])) = v
} | go | func PutUint32(b []byte, v uint32) {
if l := len(b); l != 4 {
panic(fmt.Sprintf("PutUint32: unexpected byte slice length: %d", l))
}
*(*uint32)(unsafe.Pointer(&b[0])) = v
} | [
"func",
"PutUint32",
"(",
"b",
"[",
"]",
"byte",
",",
"v",
"uint32",
")",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"4",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"... | // PutUint32 encodes a uint32 into b using the host machine's native endianness.
// If b is not exactly 4 bytes in length, PutUint32 will panic. | [
"PutUint32",
"encodes",
"a",
"uint32",
"into",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"4",
"bytes",
"in",
"length",
"PutUint32",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L30-L36 |
141,343 | mdlayher/netlink | nlenc/int.go | PutUint64 | func PutUint64(b []byte, v uint64) {
if l := len(b); l != 8 {
panic(fmt.Sprintf("PutUint64: unexpected byte slice length: %d", l))
}
*(*uint64)(unsafe.Pointer(&b[0])) = v
} | go | func PutUint64(b []byte, v uint64) {
if l := len(b); l != 8 {
panic(fmt.Sprintf("PutUint64: unexpected byte slice length: %d", l))
}
*(*uint64)(unsafe.Pointer(&b[0])) = v
} | [
"func",
"PutUint64",
"(",
"b",
"[",
"]",
"byte",
",",
"v",
"uint64",
")",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"8",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"... | // PutUint64 encodes a uint64 into b using the host machine's native endianness.
// If b is not exactly 8 bytes in length, PutUint64 will panic. | [
"PutUint64",
"encodes",
"a",
"uint64",
"into",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"8",
"bytes",
"in",
"length",
"PutUint64",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L40-L46 |
141,344 | mdlayher/netlink | nlenc/int.go | PutInt32 | func PutInt32(b []byte, v int32) {
if l := len(b); l != 4 {
panic(fmt.Sprintf("PutInt32: unexpected byte slice length: %d", l))
}
*(*int32)(unsafe.Pointer(&b[0])) = v
} | go | func PutInt32(b []byte, v int32) {
if l := len(b); l != 4 {
panic(fmt.Sprintf("PutInt32: unexpected byte slice length: %d", l))
}
*(*int32)(unsafe.Pointer(&b[0])) = v
} | [
"func",
"PutInt32",
"(",
"b",
"[",
"]",
"byte",
",",
"v",
"int32",
")",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"4",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"*"... | // PutInt32 encodes a int32 into b using the host machine's native endianness.
// If b is not exactly 4 bytes in length, PutInt32 will panic. | [
"PutInt32",
"encodes",
"a",
"int32",
"into",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"4",
"bytes",
"in",
"length",
"PutInt32",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L50-L56 |
141,345 | mdlayher/netlink | nlenc/int.go | Uint8 | func Uint8(b []byte) uint8 {
if l := len(b); l != 1 {
panic(fmt.Sprintf("Uint8: unexpected byte slice length: %d", l))
}
return b[0]
} | go | func Uint8(b []byte) uint8 {
if l := len(b); l != 1 {
panic(fmt.Sprintf("Uint8: unexpected byte slice length: %d", l))
}
return b[0]
} | [
"func",
"Uint8",
"(",
"b",
"[",
"]",
"byte",
")",
"uint8",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"1",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"return",
"b",
"... | // Uint8 decodes a uint8 from b.
// If b is not exactly 1 byte in length, Uint8 will panic. | [
"Uint8",
"decodes",
"a",
"uint8",
"from",
"b",
".",
"If",
"b",
"is",
"not",
"exactly",
"1",
"byte",
"in",
"length",
"Uint8",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L60-L66 |
141,346 | mdlayher/netlink | nlenc/int.go | Uint16 | func Uint16(b []byte) uint16 {
if l := len(b); l != 2 {
panic(fmt.Sprintf("Uint16: unexpected byte slice length: %d", l))
}
return *(*uint16)(unsafe.Pointer(&b[0]))
} | go | func Uint16(b []byte) uint16 {
if l := len(b); l != 2 {
panic(fmt.Sprintf("Uint16: unexpected byte slice length: %d", l))
}
return *(*uint16)(unsafe.Pointer(&b[0]))
} | [
"func",
"Uint16",
"(",
"b",
"[",
"]",
"byte",
")",
"uint16",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"2",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"return",
"*",
... | // Uint16 decodes a uint16 from b using the host machine's native endianness.
// If b is not exactly 2 bytes in length, Uint16 will panic. | [
"Uint16",
"decodes",
"a",
"uint16",
"from",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"2",
"bytes",
"in",
"length",
"Uint16",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L70-L76 |
141,347 | mdlayher/netlink | nlenc/int.go | Uint32 | func Uint32(b []byte) uint32 {
if l := len(b); l != 4 {
panic(fmt.Sprintf("Uint32: unexpected byte slice length: %d", l))
}
return *(*uint32)(unsafe.Pointer(&b[0]))
} | go | func Uint32(b []byte) uint32 {
if l := len(b); l != 4 {
panic(fmt.Sprintf("Uint32: unexpected byte slice length: %d", l))
}
return *(*uint32)(unsafe.Pointer(&b[0]))
} | [
"func",
"Uint32",
"(",
"b",
"[",
"]",
"byte",
")",
"uint32",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"4",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"return",
"*",
... | // Uint32 decodes a uint32 from b using the host machine's native endianness.
// If b is not exactly 4 bytes in length, Uint32 will panic. | [
"Uint32",
"decodes",
"a",
"uint32",
"from",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"4",
"bytes",
"in",
"length",
"Uint32",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L80-L86 |
141,348 | mdlayher/netlink | nlenc/int.go | Uint64 | func Uint64(b []byte) uint64 {
if l := len(b); l != 8 {
panic(fmt.Sprintf("Uint64: unexpected byte slice length: %d", l))
}
return *(*uint64)(unsafe.Pointer(&b[0]))
} | go | func Uint64(b []byte) uint64 {
if l := len(b); l != 8 {
panic(fmt.Sprintf("Uint64: unexpected byte slice length: %d", l))
}
return *(*uint64)(unsafe.Pointer(&b[0]))
} | [
"func",
"Uint64",
"(",
"b",
"[",
"]",
"byte",
")",
"uint64",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"8",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"return",
"*",
... | // Uint64 decodes a uint64 from b using the host machine's native endianness.
// If b is not exactly 8 bytes in length, Uint64 will panic. | [
"Uint64",
"decodes",
"a",
"uint64",
"from",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"8",
"bytes",
"in",
"length",
"Uint64",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L90-L96 |
141,349 | mdlayher/netlink | nlenc/int.go | Int32 | func Int32(b []byte) int32 {
if l := len(b); l != 4 {
panic(fmt.Sprintf("Int32: unexpected byte slice length: %d", l))
}
return *(*int32)(unsafe.Pointer(&b[0]))
} | go | func Int32(b []byte) int32 {
if l := len(b); l != 4 {
panic(fmt.Sprintf("Int32: unexpected byte slice length: %d", l))
}
return *(*int32)(unsafe.Pointer(&b[0]))
} | [
"func",
"Int32",
"(",
"b",
"[",
"]",
"byte",
")",
"int32",
"{",
"if",
"l",
":=",
"len",
"(",
"b",
")",
";",
"l",
"!=",
"4",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
")",
"\n",
"}",
"\n\n",
"return",
"*",
"... | // Int32 decodes an int32 from b using the host machine's native endianness.
// If b is not exactly 4 bytes in length, Int32 will panic. | [
"Int32",
"decodes",
"an",
"int32",
"from",
"b",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"If",
"b",
"is",
"not",
"exactly",
"4",
"bytes",
"in",
"length",
"Int32",
"will",
"panic",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L100-L106 |
141,350 | mdlayher/netlink | nlenc/int.go | Uint8Bytes | func Uint8Bytes(v uint8) []byte {
b := make([]byte, 1)
PutUint8(b, v)
return b
} | go | func Uint8Bytes(v uint8) []byte {
b := make([]byte, 1)
PutUint8(b, v)
return b
} | [
"func",
"Uint8Bytes",
"(",
"v",
"uint8",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
")",
"\n",
"PutUint8",
"(",
"b",
",",
"v",
")",
"\n",
"return",
"b",
"\n",
"}"
] | // Uint8Bytes encodes a uint8 into a newly-allocated byte slice. It is a
// shortcut for allocating a new byte slice and filling it using PutUint8. | [
"Uint8Bytes",
"encodes",
"a",
"uint8",
"into",
"a",
"newly",
"-",
"allocated",
"byte",
"slice",
".",
"It",
"is",
"a",
"shortcut",
"for",
"allocating",
"a",
"new",
"byte",
"slice",
"and",
"filling",
"it",
"using",
"PutUint8",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L110-L114 |
141,351 | mdlayher/netlink | nlenc/int.go | Uint16Bytes | func Uint16Bytes(v uint16) []byte {
b := make([]byte, 2)
PutUint16(b, v)
return b
} | go | func Uint16Bytes(v uint16) []byte {
b := make([]byte, 2)
PutUint16(b, v)
return b
} | [
"func",
"Uint16Bytes",
"(",
"v",
"uint16",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"2",
")",
"\n",
"PutUint16",
"(",
"b",
",",
"v",
")",
"\n",
"return",
"b",
"\n",
"}"
] | // Uint16Bytes encodes a uint16 into a newly-allocated byte slice using the
// host machine's native endianness. It is a shortcut for allocating a new
// byte slice and filling it using PutUint16. | [
"Uint16Bytes",
"encodes",
"a",
"uint16",
"into",
"a",
"newly",
"-",
"allocated",
"byte",
"slice",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"It",
"is",
"a",
"shortcut",
"for",
"allocating",
"a",
"new",
"byte",
"slice",
"and",
"fi... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L119-L123 |
141,352 | mdlayher/netlink | nlenc/int.go | Uint32Bytes | func Uint32Bytes(v uint32) []byte {
b := make([]byte, 4)
PutUint32(b, v)
return b
} | go | func Uint32Bytes(v uint32) []byte {
b := make([]byte, 4)
PutUint32(b, v)
return b
} | [
"func",
"Uint32Bytes",
"(",
"v",
"uint32",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"PutUint32",
"(",
"b",
",",
"v",
")",
"\n",
"return",
"b",
"\n",
"}"
] | // Uint32Bytes encodes a uint32 into a newly-allocated byte slice using the
// host machine's native endianness. It is a shortcut for allocating a new
// byte slice and filling it using PutUint32. | [
"Uint32Bytes",
"encodes",
"a",
"uint32",
"into",
"a",
"newly",
"-",
"allocated",
"byte",
"slice",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"It",
"is",
"a",
"shortcut",
"for",
"allocating",
"a",
"new",
"byte",
"slice",
"and",
"fi... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L128-L132 |
141,353 | mdlayher/netlink | nlenc/int.go | Uint64Bytes | func Uint64Bytes(v uint64) []byte {
b := make([]byte, 8)
PutUint64(b, v)
return b
} | go | func Uint64Bytes(v uint64) []byte {
b := make([]byte, 8)
PutUint64(b, v)
return b
} | [
"func",
"Uint64Bytes",
"(",
"v",
"uint64",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"8",
")",
"\n",
"PutUint64",
"(",
"b",
",",
"v",
")",
"\n",
"return",
"b",
"\n",
"}"
] | // Uint64Bytes encodes a uint64 into a newly-allocated byte slice using the
// host machine's native endianness. It is a shortcut for allocating a new
// byte slice and filling it using PutUint64. | [
"Uint64Bytes",
"encodes",
"a",
"uint64",
"into",
"a",
"newly",
"-",
"allocated",
"byte",
"slice",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"It",
"is",
"a",
"shortcut",
"for",
"allocating",
"a",
"new",
"byte",
"slice",
"and",
"fi... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L137-L141 |
141,354 | mdlayher/netlink | nlenc/int.go | Int32Bytes | func Int32Bytes(v int32) []byte {
b := make([]byte, 4)
PutInt32(b, v)
return b
} | go | func Int32Bytes(v int32) []byte {
b := make([]byte, 4)
PutInt32(b, v)
return b
} | [
"func",
"Int32Bytes",
"(",
"v",
"int32",
")",
"[",
"]",
"byte",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"PutInt32",
"(",
"b",
",",
"v",
")",
"\n",
"return",
"b",
"\n",
"}"
] | // Int32Bytes encodes a int32 into a newly-allocated byte slice using the
// host machine's native endianness. It is a shortcut for allocating a new
// byte slice and filling it using PutInt32. | [
"Int32Bytes",
"encodes",
"a",
"int32",
"into",
"a",
"newly",
"-",
"allocated",
"byte",
"slice",
"using",
"the",
"host",
"machine",
"s",
"native",
"endianness",
".",
"It",
"is",
"a",
"shortcut",
"for",
"allocating",
"a",
"new",
"byte",
"slice",
"and",
"fill... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/int.go#L146-L150 |
141,355 | mdlayher/netlink | nlenc/endian.go | NativeEndian | func NativeEndian() binary.ByteOrder {
// Determine endianness by storing a uint16 in a byte slice.
b := Uint16Bytes(1)
if b[0] == 1 {
return binary.LittleEndian
}
return binary.BigEndian
} | go | func NativeEndian() binary.ByteOrder {
// Determine endianness by storing a uint16 in a byte slice.
b := Uint16Bytes(1)
if b[0] == 1 {
return binary.LittleEndian
}
return binary.BigEndian
} | [
"func",
"NativeEndian",
"(",
")",
"binary",
".",
"ByteOrder",
"{",
"// Determine endianness by storing a uint16 in a byte slice.",
"b",
":=",
"Uint16Bytes",
"(",
"1",
")",
"\n",
"if",
"b",
"[",
"0",
"]",
"==",
"1",
"{",
"return",
"binary",
".",
"LittleEndian",
... | // NativeEndian returns the native byte order of this system. | [
"NativeEndian",
"returns",
"the",
"native",
"byte",
"order",
"of",
"this",
"system",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/nlenc/endian.go#L6-L14 |
141,356 | mdlayher/netlink | message.go | String | func (f HeaderFlags) String() string {
names := []string{
"request",
"multi",
"acknowledge",
"echo",
"dumpinterrupted",
"dumpfiltered",
}
var s string
left := uint(f)
for i, name := range names {
if f&(1<<uint(i)) != 0 {
if s != "" {
s += "|"
}
s += name
left ^= (1 << uint(i))
... | go | func (f HeaderFlags) String() string {
names := []string{
"request",
"multi",
"acknowledge",
"echo",
"dumpinterrupted",
"dumpfiltered",
}
var s string
left := uint(f)
for i, name := range names {
if f&(1<<uint(i)) != 0 {
if s != "" {
s += "|"
}
s += name
left ^= (1 << uint(i))
... | [
"func",
"(",
"f",
"HeaderFlags",
")",
"String",
"(",
")",
"string",
"{",
"names",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"\n\n",
"var",
"s",
... | // String returns the string representation of a HeaderFlags. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"HeaderFlags",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/message.go#L77-L115 |
141,357 | mdlayher/netlink | message.go | String | func (t HeaderType) String() string {
switch t {
case Noop:
return "noop"
case Error:
return "error"
case Done:
return "done"
case Overrun:
return "overrun"
default:
return fmt.Sprintf("unknown(%d)", t)
}
} | go | func (t HeaderType) String() string {
switch t {
case Noop:
return "noop"
case Error:
return "error"
case Done:
return "done"
case Overrun:
return "overrun"
default:
return fmt.Sprintf("unknown(%d)", t)
}
} | [
"func",
"(",
"t",
"HeaderType",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"t",
"{",
"case",
"Noop",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Error",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Done",
":",
"return",
"\"",
"\"",
"\n",
"case",
... | // String returns the string representation of a HeaderType. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"HeaderType",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/message.go#L136-L149 |
141,358 | mdlayher/netlink | message.go | MarshalBinary | func (m Message) MarshalBinary() ([]byte, error) {
ml := nlmsgAlign(int(m.Header.Length))
if ml < nlmsgHeaderLen || ml != int(m.Header.Length) {
return nil, errIncorrectMessageLength
}
b := make([]byte, ml)
nlenc.PutUint32(b[0:4], m.Header.Length)
nlenc.PutUint16(b[4:6], uint16(m.Header.Type))
nlenc.PutUint1... | go | func (m Message) MarshalBinary() ([]byte, error) {
ml := nlmsgAlign(int(m.Header.Length))
if ml < nlmsgHeaderLen || ml != int(m.Header.Length) {
return nil, errIncorrectMessageLength
}
b := make([]byte, ml)
nlenc.PutUint32(b[0:4], m.Header.Length)
nlenc.PutUint16(b[4:6], uint16(m.Header.Type))
nlenc.PutUint1... | [
"func",
"(",
"m",
"Message",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"ml",
":=",
"nlmsgAlign",
"(",
"int",
"(",
"m",
".",
"Header",
".",
"Length",
")",
")",
"\n",
"if",
"ml",
"<",
"nlmsgHeaderLen",
"||",
"ml... | // MarshalBinary marshals a Message into a byte slice. | [
"MarshalBinary",
"marshals",
"a",
"Message",
"into",
"a",
"byte",
"slice",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/message.go#L185-L201 |
141,359 | mdlayher/netlink | message.go | UnmarshalBinary | func (m *Message) UnmarshalBinary(b []byte) error {
if len(b) < nlmsgHeaderLen {
return errShortMessage
}
if len(b) != nlmsgAlign(len(b)) {
return errUnalignedMessage
}
// Don't allow misleading length
m.Header.Length = nlenc.Uint32(b[0:4])
if int(m.Header.Length) != len(b) {
return errShortMessage
}
m... | go | func (m *Message) UnmarshalBinary(b []byte) error {
if len(b) < nlmsgHeaderLen {
return errShortMessage
}
if len(b) != nlmsgAlign(len(b)) {
return errUnalignedMessage
}
// Don't allow misleading length
m.Header.Length = nlenc.Uint32(b[0:4])
if int(m.Header.Length) != len(b) {
return errShortMessage
}
m... | [
"func",
"(",
"m",
"*",
"Message",
")",
"UnmarshalBinary",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"b",
")",
"<",
"nlmsgHeaderLen",
"{",
"return",
"errShortMessage",
"\n",
"}",
"\n",
"if",
"len",
"(",
"b",
")",
"!=",
"nlmsgA... | // UnmarshalBinary unmarshals the contents of a byte slice into a Message. | [
"UnmarshalBinary",
"unmarshals",
"the",
"contents",
"of",
"a",
"byte",
"slice",
"into",
"a",
"Message",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/message.go#L204-L225 |
141,360 | mdlayher/netlink | message.go | checkMessage | func checkMessage(m Message) error {
// NB: All non-nil errors returned from this function *must* be of type
// OpError in order to maintain the appropriate contract with callers of
// this package.
const success = 0
// Per libnl documentation, only messages that indicate type error can
// contain error codes:
... | go | func checkMessage(m Message) error {
// NB: All non-nil errors returned from this function *must* be of type
// OpError in order to maintain the appropriate contract with callers of
// this package.
const success = 0
// Per libnl documentation, only messages that indicate type error can
// contain error codes:
... | [
"func",
"checkMessage",
"(",
"m",
"Message",
")",
"error",
"{",
"// NB: All non-nil errors returned from this function *must* be of type",
"// OpError in order to maintain the appropriate contract with callers of",
"// this package.",
"const",
"success",
"=",
"0",
"\n\n",
"// Per lib... | // checkMessage checks a single Message for netlink errors. | [
"checkMessage",
"checks",
"a",
"single",
"Message",
"for",
"netlink",
"errors",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/message.go#L228-L260 |
141,361 | mdlayher/netlink | attribute.go | marshal | func (a *Attribute) marshal(b []byte) (int, error) {
if int(a.Length) < nlaHeaderLen {
return 0, errInvalidAttribute
}
nlenc.PutUint16(b[0:2], a.Length)
nlenc.PutUint16(b[2:4], a.Type)
n := copy(b[nlaHeaderLen:], a.Data)
return nlaHeaderLen + nlaAlign(n), nil
} | go | func (a *Attribute) marshal(b []byte) (int, error) {
if int(a.Length) < nlaHeaderLen {
return 0, errInvalidAttribute
}
nlenc.PutUint16(b[0:2], a.Length)
nlenc.PutUint16(b[2:4], a.Type)
n := copy(b[nlaHeaderLen:], a.Data)
return nlaHeaderLen + nlaAlign(n), nil
} | [
"func",
"(",
"a",
"*",
"Attribute",
")",
"marshal",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"int",
"(",
"a",
".",
"Length",
")",
"<",
"nlaHeaderLen",
"{",
"return",
"0",
",",
"errInvalidAttribute",
"\n",
"}",
"\... | // marshal marshals the contents of a into b and returns the number of bytes
// written to b, including attribute alignment padding. | [
"marshal",
"marshals",
"the",
"contents",
"of",
"a",
"into",
"b",
"and",
"returns",
"the",
"number",
"of",
"bytes",
"written",
"to",
"b",
"including",
"attribute",
"alignment",
"padding",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L29-L39 |
141,362 | mdlayher/netlink | attribute.go | unmarshal | func (a *Attribute) unmarshal(b []byte) error {
if len(b) < nlaHeaderLen {
return errInvalidAttribute
}
a.Length = nlenc.Uint16(b[0:2])
a.Type = nlenc.Uint16(b[2:4])
if int(a.Length) > len(b) {
return errInvalidAttribute
}
switch {
// No length, no data
case a.Length == 0:
a.Data = make([]byte, 0)
//... | go | func (a *Attribute) unmarshal(b []byte) error {
if len(b) < nlaHeaderLen {
return errInvalidAttribute
}
a.Length = nlenc.Uint16(b[0:2])
a.Type = nlenc.Uint16(b[2:4])
if int(a.Length) > len(b) {
return errInvalidAttribute
}
switch {
// No length, no data
case a.Length == 0:
a.Data = make([]byte, 0)
//... | [
"func",
"(",
"a",
"*",
"Attribute",
")",
"unmarshal",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"b",
")",
"<",
"nlaHeaderLen",
"{",
"return",
"errInvalidAttribute",
"\n",
"}",
"\n\n",
"a",
".",
"Length",
"=",
"nlenc",
".",
"U... | // unmarshal unmarshals the contents of a byte slice into an Attribute. | [
"unmarshal",
"unmarshals",
"the",
"contents",
"of",
"a",
"byte",
"slice",
"into",
"an",
"Attribute",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L42-L68 |
141,363 | mdlayher/netlink | attribute.go | MarshalAttributes | func MarshalAttributes(attrs []Attribute) ([]byte, error) {
// Count how many bytes we should allocate to store each attribute's contents.
var c int
for _, a := range attrs {
c += nlaHeaderLen + nlaAlign(len(a.Data))
}
// Advance through b with idx to place attribute data at the correct offset.
var idx int
b ... | go | func MarshalAttributes(attrs []Attribute) ([]byte, error) {
// Count how many bytes we should allocate to store each attribute's contents.
var c int
for _, a := range attrs {
c += nlaHeaderLen + nlaAlign(len(a.Data))
}
// Advance through b with idx to place attribute data at the correct offset.
var idx int
b ... | [
"func",
"MarshalAttributes",
"(",
"attrs",
"[",
"]",
"Attribute",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Count how many bytes we should allocate to store each attribute's contents.",
"var",
"c",
"int",
"\n",
"for",
"_",
",",
"a",
":=",
"range",
... | // MarshalAttributes packs a slice of Attributes into a single byte slice.
// In most cases, the Length field of each Attribute should be set to 0, so it
// can be calculated and populated automatically for each Attribute. | [
"MarshalAttributes",
"packs",
"a",
"slice",
"of",
"Attributes",
"into",
"a",
"single",
"byte",
"slice",
".",
"In",
"most",
"cases",
"the",
"Length",
"field",
"of",
"each",
"Attribute",
"should",
"be",
"set",
"to",
"0",
"so",
"it",
"can",
"be",
"calculated"... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L73-L98 |
141,364 | mdlayher/netlink | attribute.go | UnmarshalAttributes | func UnmarshalAttributes(b []byte) ([]Attribute, error) {
var attrs []Attribute
var i int
for {
if i > len(b) || len(b[i:]) == 0 {
break
}
var a Attribute
if err := (&a).unmarshal(b[i:]); err != nil {
return nil, err
}
if a.Length == 0 {
i += nlaHeaderLen
continue
}
i += nlaAlign(int(a... | go | func UnmarshalAttributes(b []byte) ([]Attribute, error) {
var attrs []Attribute
var i int
for {
if i > len(b) || len(b[i:]) == 0 {
break
}
var a Attribute
if err := (&a).unmarshal(b[i:]); err != nil {
return nil, err
}
if a.Length == 0 {
i += nlaHeaderLen
continue
}
i += nlaAlign(int(a... | [
"func",
"UnmarshalAttributes",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"Attribute",
",",
"error",
")",
"{",
"var",
"attrs",
"[",
"]",
"Attribute",
"\n",
"var",
"i",
"int",
"\n",
"for",
"{",
"if",
"i",
">",
"len",
"(",
"b",
")",
"||",
"l... | // UnmarshalAttributes unpacks a slice of Attributes from a single byte slice.
//
// It is recommend to use the AttributeDecoder type where possible instead of calling
// UnmarshalAttributes and using package nlenc functions directly. | [
"UnmarshalAttributes",
"unpacks",
"a",
"slice",
"of",
"Attributes",
"from",
"a",
"single",
"byte",
"slice",
".",
"It",
"is",
"recommend",
"to",
"use",
"the",
"AttributeDecoder",
"type",
"where",
"possible",
"instead",
"of",
"calling",
"UnmarshalAttributes",
"and",... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L104-L128 |
141,365 | mdlayher/netlink | attribute.go | NewAttributeDecoder | func NewAttributeDecoder(b []byte) (*AttributeDecoder, error) {
attrs, err := UnmarshalAttributes(b)
if err != nil {
return nil, err
}
return &AttributeDecoder{
// By default, use native byte order.
ByteOrder: nlenc.NativeEndian(),
attrs: attrs,
}, nil
} | go | func NewAttributeDecoder(b []byte) (*AttributeDecoder, error) {
attrs, err := UnmarshalAttributes(b)
if err != nil {
return nil, err
}
return &AttributeDecoder{
// By default, use native byte order.
ByteOrder: nlenc.NativeEndian(),
attrs: attrs,
}, nil
} | [
"func",
"NewAttributeDecoder",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"*",
"AttributeDecoder",
",",
"error",
")",
"{",
"attrs",
",",
"err",
":=",
"UnmarshalAttributes",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"... | // NewAttributeDecoder creates an AttributeDecoder that unpacks Attributes
// from b and prepares the decoder for iteration. | [
"NewAttributeDecoder",
"creates",
"an",
"AttributeDecoder",
"that",
"unpacks",
"Attributes",
"from",
"b",
"and",
"prepares",
"the",
"decoder",
"for",
"iteration",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L157-L169 |
141,366 | mdlayher/netlink | attribute.go | Next | func (ad *AttributeDecoder) Next() bool {
if ad.err != nil {
// Hit an error, stop iteration.
return false
}
ad.i++
// More attributes?
return len(ad.attrs) >= ad.i
} | go | func (ad *AttributeDecoder) Next() bool {
if ad.err != nil {
// Hit an error, stop iteration.
return false
}
ad.i++
// More attributes?
return len(ad.attrs) >= ad.i
} | [
"func",
"(",
"ad",
"*",
"AttributeDecoder",
")",
"Next",
"(",
")",
"bool",
"{",
"if",
"ad",
".",
"err",
"!=",
"nil",
"{",
"// Hit an error, stop iteration.",
"return",
"false",
"\n",
"}",
"\n\n",
"ad",
".",
"i",
"++",
"\n\n",
"// More attributes?",
"return... | // Next advances the decoder to the next netlink attribute. It returns false
// when no more attributes are present, or an error was encountered. | [
"Next",
"advances",
"the",
"decoder",
"to",
"the",
"next",
"netlink",
"attribute",
".",
"It",
"returns",
"false",
"when",
"no",
"more",
"attributes",
"are",
"present",
"or",
"an",
"error",
"was",
"encountered",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L173-L183 |
141,367 | mdlayher/netlink | attribute.go | Bytes | func (ad *AttributeDecoder) Bytes() []byte {
src := ad.data()
dest := make([]byte, len(src))
copy(dest, src)
return dest
} | go | func (ad *AttributeDecoder) Bytes() []byte {
src := ad.data()
dest := make([]byte, len(src))
copy(dest, src)
return dest
} | [
"func",
"(",
"ad",
"*",
"AttributeDecoder",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"src",
":=",
"ad",
".",
"data",
"(",
")",
"\n",
"dest",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"src",
")",
")",
"\n",
"copy",
"(",
"dest... | // Bytes returns the raw bytes of the current Attribute's data. | [
"Bytes",
"returns",
"the",
"raw",
"bytes",
"of",
"the",
"current",
"Attribute",
"s",
"data",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L207-L212 |
141,368 | mdlayher/netlink | attribute.go | String | func (ad *AttributeDecoder) String() string {
if ad.err != nil {
return ""
}
return nlenc.String(ad.data())
} | go | func (ad *AttributeDecoder) String() string {
if ad.err != nil {
return ""
}
return nlenc.String(ad.data())
} | [
"func",
"(",
"ad",
"*",
"AttributeDecoder",
")",
"String",
"(",
")",
"string",
"{",
"if",
"ad",
".",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"nlenc",
".",
"String",
"(",
"ad",
".",
"data",
"(",
")",
")",
"\n",
... | // String returns the string representation of the current Attribute's data. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"the",
"current",
"Attribute",
"s",
"data",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L215-L221 |
141,369 | mdlayher/netlink | attribute.go | Uint8 | func (ad *AttributeDecoder) Uint8() uint8 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 1 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint8; length: %d", ad.Type(), len(b))
return 0
}
return uint8(b[0])
} | go | func (ad *AttributeDecoder) Uint8() uint8 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 1 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint8; length: %d", ad.Type(), len(b))
return 0
}
return uint8(b[0])
} | [
"func",
"(",
"ad",
"*",
"AttributeDecoder",
")",
"Uint8",
"(",
")",
"uint8",
"{",
"if",
"ad",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"b",
":=",
"ad",
".",
"data",
"(",
")",
"\n",
"if",
"len",
"(",
"b",
")",
"!=",
"1",... | // Uint8 returns the uint8 representation of the current Attribute's data. | [
"Uint8",
"returns",
"the",
"uint8",
"representation",
"of",
"the",
"current",
"Attribute",
"s",
"data",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L224-L236 |
141,370 | mdlayher/netlink | attribute.go | Uint16 | func (ad *AttributeDecoder) Uint16() uint16 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 2 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint16; length: %d", ad.Type(), len(b))
return 0
}
return ad.ByteOrder.Uint16(b)
} | go | func (ad *AttributeDecoder) Uint16() uint16 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 2 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint16; length: %d", ad.Type(), len(b))
return 0
}
return ad.ByteOrder.Uint16(b)
} | [
"func",
"(",
"ad",
"*",
"AttributeDecoder",
")",
"Uint16",
"(",
")",
"uint16",
"{",
"if",
"ad",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"b",
":=",
"ad",
".",
"data",
"(",
")",
"\n",
"if",
"len",
"(",
"b",
")",
"!=",
"2... | // Uint16 returns the uint16 representation of the current Attribute's data. | [
"Uint16",
"returns",
"the",
"uint16",
"representation",
"of",
"the",
"current",
"Attribute",
"s",
"data",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L239-L251 |
141,371 | mdlayher/netlink | attribute.go | Uint32 | func (ad *AttributeDecoder) Uint32() uint32 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 4 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint32; length: %d", ad.Type(), len(b))
return 0
}
return ad.ByteOrder.Uint32(b)
} | go | func (ad *AttributeDecoder) Uint32() uint32 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 4 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint32; length: %d", ad.Type(), len(b))
return 0
}
return ad.ByteOrder.Uint32(b)
} | [
"func",
"(",
"ad",
"*",
"AttributeDecoder",
")",
"Uint32",
"(",
")",
"uint32",
"{",
"if",
"ad",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"b",
":=",
"ad",
".",
"data",
"(",
")",
"\n",
"if",
"len",
"(",
"b",
")",
"!=",
"4... | // Uint32 returns the uint32 representation of the current Attribute's data. | [
"Uint32",
"returns",
"the",
"uint32",
"representation",
"of",
"the",
"current",
"Attribute",
"s",
"data",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L254-L266 |
141,372 | mdlayher/netlink | attribute.go | Uint64 | func (ad *AttributeDecoder) Uint64() uint64 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 8 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint64; length: %d", ad.Type(), len(b))
return 0
}
return ad.ByteOrder.Uint64(b)
} | go | func (ad *AttributeDecoder) Uint64() uint64 {
if ad.err != nil {
return 0
}
b := ad.data()
if len(b) != 8 {
ad.err = fmt.Errorf("netlink: attribute %d is not a uint64; length: %d", ad.Type(), len(b))
return 0
}
return ad.ByteOrder.Uint64(b)
} | [
"func",
"(",
"ad",
"*",
"AttributeDecoder",
")",
"Uint64",
"(",
")",
"uint64",
"{",
"if",
"ad",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"b",
":=",
"ad",
".",
"data",
"(",
")",
"\n",
"if",
"len",
"(",
"b",
")",
"!=",
"8... | // Uint64 returns the uint64 representation of the current Attribute's data. | [
"Uint64",
"returns",
"the",
"uint64",
"representation",
"of",
"the",
"current",
"Attribute",
"s",
"data",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L269-L281 |
141,373 | mdlayher/netlink | attribute.go | Uint8 | func (ae *AttributeEncoder) Uint8(typ uint16, v uint8) {
if ae.err != nil {
return
}
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: []byte{v},
})
} | go | func (ae *AttributeEncoder) Uint8(typ uint16, v uint8) {
if ae.err != nil {
return
}
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: []byte{v},
})
} | [
"func",
"(",
"ae",
"*",
"AttributeEncoder",
")",
"Uint8",
"(",
"typ",
"uint16",
",",
"v",
"uint8",
")",
"{",
"if",
"ae",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"ae",
".",
"attrs",
"=",
"append",
"(",
"ae",
".",
"attrs",
",",
... | // Uint8 encodes uint8 data into an Attribute specified by typ. | [
"Uint8",
"encodes",
"uint8",
"data",
"into",
"an",
"Attribute",
"specified",
"by",
"typ",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L331-L340 |
141,374 | mdlayher/netlink | attribute.go | Uint16 | func (ae *AttributeEncoder) Uint16(typ uint16, v uint16) {
if ae.err != nil {
return
}
b := make([]byte, 2)
ae.ByteOrder.PutUint16(b, v)
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | go | func (ae *AttributeEncoder) Uint16(typ uint16, v uint16) {
if ae.err != nil {
return
}
b := make([]byte, 2)
ae.ByteOrder.PutUint16(b, v)
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | [
"func",
"(",
"ae",
"*",
"AttributeEncoder",
")",
"Uint16",
"(",
"typ",
"uint16",
",",
"v",
"uint16",
")",
"{",
"if",
"ae",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"2",
")",
"\n",... | // Uint16 encodes uint16 data into an Attribute specified by typ. | [
"Uint16",
"encodes",
"uint16",
"data",
"into",
"an",
"Attribute",
"specified",
"by",
"typ",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L343-L355 |
141,375 | mdlayher/netlink | attribute.go | Uint32 | func (ae *AttributeEncoder) Uint32(typ uint16, v uint32) {
if ae.err != nil {
return
}
b := make([]byte, 4)
ae.ByteOrder.PutUint32(b, v)
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | go | func (ae *AttributeEncoder) Uint32(typ uint16, v uint32) {
if ae.err != nil {
return
}
b := make([]byte, 4)
ae.ByteOrder.PutUint32(b, v)
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | [
"func",
"(",
"ae",
"*",
"AttributeEncoder",
")",
"Uint32",
"(",
"typ",
"uint16",
",",
"v",
"uint32",
")",
"{",
"if",
"ae",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",... | // Uint32 encodes uint32 data into an Attribute specified by typ. | [
"Uint32",
"encodes",
"uint32",
"data",
"into",
"an",
"Attribute",
"specified",
"by",
"typ",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L358-L370 |
141,376 | mdlayher/netlink | attribute.go | Uint64 | func (ae *AttributeEncoder) Uint64(typ uint16, v uint64) {
if ae.err != nil {
return
}
b := make([]byte, 8)
ae.ByteOrder.PutUint64(b, v)
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | go | func (ae *AttributeEncoder) Uint64(typ uint16, v uint64) {
if ae.err != nil {
return
}
b := make([]byte, 8)
ae.ByteOrder.PutUint64(b, v)
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | [
"func",
"(",
"ae",
"*",
"AttributeEncoder",
")",
"Uint64",
"(",
"typ",
"uint16",
",",
"v",
"uint64",
")",
"{",
"if",
"ae",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"8",
")",
"\n",... | // Uint64 encodes uint64 data into an Attribute specified by typ. | [
"Uint64",
"encodes",
"uint64",
"data",
"into",
"an",
"Attribute",
"specified",
"by",
"typ",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L373-L385 |
141,377 | mdlayher/netlink | attribute.go | String | func (ae *AttributeEncoder) String(typ uint16, s string) {
if ae.err != nil {
return
}
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: nlenc.Bytes(s),
})
} | go | func (ae *AttributeEncoder) String(typ uint16, s string) {
if ae.err != nil {
return
}
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: nlenc.Bytes(s),
})
} | [
"func",
"(",
"ae",
"*",
"AttributeEncoder",
")",
"String",
"(",
"typ",
"uint16",
",",
"s",
"string",
")",
"{",
"if",
"ae",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"ae",
".",
"attrs",
"=",
"append",
"(",
"ae",
".",
"attrs",
",",... | // String encodes string s as a null-terminated string into an Attribute
// specified by typ. | [
"String",
"encodes",
"string",
"s",
"as",
"a",
"null",
"-",
"terminated",
"string",
"into",
"an",
"Attribute",
"specified",
"by",
"typ",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L389-L398 |
141,378 | mdlayher/netlink | attribute.go | Bytes | func (ae *AttributeEncoder) Bytes(typ uint16, b []byte) {
if ae.err != nil {
return
}
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | go | func (ae *AttributeEncoder) Bytes(typ uint16, b []byte) {
if ae.err != nil {
return
}
ae.attrs = append(ae.attrs, Attribute{
Type: typ,
Data: b,
})
} | [
"func",
"(",
"ae",
"*",
"AttributeEncoder",
")",
"Bytes",
"(",
"typ",
"uint16",
",",
"b",
"[",
"]",
"byte",
")",
"{",
"if",
"ae",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"ae",
".",
"attrs",
"=",
"append",
"(",
"ae",
".",
"att... | // Bytes embeds raw byte data into an Attribute specified by typ. | [
"Bytes",
"embeds",
"raw",
"byte",
"data",
"into",
"an",
"Attribute",
"specified",
"by",
"typ",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L401-L410 |
141,379 | mdlayher/netlink | attribute.go | Encode | func (ae *AttributeEncoder) Encode() ([]byte, error) {
if ae.err != nil {
return nil, ae.err
}
return MarshalAttributes(ae.attrs)
} | go | func (ae *AttributeEncoder) Encode() ([]byte, error) {
if ae.err != nil {
return nil, ae.err
}
return MarshalAttributes(ae.attrs)
} | [
"func",
"(",
"ae",
"*",
"AttributeEncoder",
")",
"Encode",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"ae",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"ae",
".",
"err",
"\n",
"}",
"\n\n",
"return",
"MarshalAttributes",
... | // Encode returns the encoded bytes representing the attributes. | [
"Encode",
"returns",
"the",
"encoded",
"bytes",
"representing",
"the",
"attributes",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/attribute.go#L436-L442 |
141,380 | mdlayher/netlink | conn.go | Dial | func Dial(family int, config *Config) (*Conn, error) {
// Use OS-specific dial() to create Socket
c, pid, err := dial(family, config)
if err != nil {
return nil, err
}
return NewConn(c, pid), nil
} | go | func Dial(family int, config *Config) (*Conn, error) {
// Use OS-specific dial() to create Socket
c, pid, err := dial(family, config)
if err != nil {
return nil, err
}
return NewConn(c, pid), nil
} | [
"func",
"Dial",
"(",
"family",
"int",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"// Use OS-specific dial() to create Socket",
"c",
",",
"pid",
",",
"err",
":=",
"dial",
"(",
"family",
",",
"config",
")",
"\n",
"if",
"... | // Dial dials a connection to netlink, using the specified netlink family.
// Config specifies optional configuration for Conn. If config is nil, a default
// configuration will be used. | [
"Dial",
"dials",
"a",
"connection",
"to",
"netlink",
"using",
"the",
"specified",
"netlink",
"family",
".",
"Config",
"specifies",
"optional",
"configuration",
"for",
"Conn",
".",
"If",
"config",
"is",
"nil",
"a",
"default",
"configuration",
"will",
"be",
"use... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L53-L61 |
141,381 | mdlayher/netlink | conn.go | NewConn | func NewConn(sock Socket, pid uint32) *Conn {
// Seed the sequence number using a random number generator.
r := rand.New(rand.NewSource(time.Now().UnixNano()))
seq := r.Uint32()
// Configure a debugger if arguments are set.
var d *debugger
if len(debugArgs) > 0 {
d = newDebugger(debugArgs)
}
return &Conn{
... | go | func NewConn(sock Socket, pid uint32) *Conn {
// Seed the sequence number using a random number generator.
r := rand.New(rand.NewSource(time.Now().UnixNano()))
seq := r.Uint32()
// Configure a debugger if arguments are set.
var d *debugger
if len(debugArgs) > 0 {
d = newDebugger(debugArgs)
}
return &Conn{
... | [
"func",
"NewConn",
"(",
"sock",
"Socket",
",",
"pid",
"uint32",
")",
"*",
"Conn",
"{",
"// Seed the sequence number using a random number generator.",
"r",
":=",
"rand",
".",
"New",
"(",
"rand",
".",
"NewSource",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Unix... | // NewConn creates a Conn using the specified Socket and PID for netlink
// communications.
//
// NewConn is primarily useful for tests. Most applications should use
// Dial instead. | [
"NewConn",
"creates",
"a",
"Conn",
"using",
"the",
"specified",
"Socket",
"and",
"PID",
"for",
"netlink",
"communications",
".",
"NewConn",
"is",
"primarily",
"useful",
"for",
"tests",
".",
"Most",
"applications",
"should",
"use",
"Dial",
"instead",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L68-L85 |
141,382 | mdlayher/netlink | conn.go | debug | func (c *Conn) debug(fn func(d *debugger)) {
if c.d == nil {
return
}
fn(c.d)
} | go | func (c *Conn) debug(fn func(d *debugger)) {
if c.d == nil {
return
}
fn(c.d)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"debug",
"(",
"fn",
"func",
"(",
"d",
"*",
"debugger",
")",
")",
"{",
"if",
"c",
".",
"d",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"fn",
"(",
"c",
".",
"d",
")",
"\n",
"}"
] | // debug executes fn with the debugger if the debugger is not nil. | [
"debug",
"executes",
"fn",
"with",
"the",
"debugger",
"if",
"the",
"debugger",
"is",
"not",
"nil",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L88-L94 |
141,383 | mdlayher/netlink | conn.go | SendMessages | func (c *Conn) SendMessages(messages []Message) ([]Message, error) {
// Wait for any concurrent calls to Execute to finish before proceeding.
c.mu.RLock()
defer c.mu.RUnlock()
for idx, m := range messages {
ml := nlmsgLength(len(m.Data))
// TODO(mdlayher): fine-tune this limit.
if ml > (1024 * 32) {
retu... | go | func (c *Conn) SendMessages(messages []Message) ([]Message, error) {
// Wait for any concurrent calls to Execute to finish before proceeding.
c.mu.RLock()
defer c.mu.RUnlock()
for idx, m := range messages {
ml := nlmsgLength(len(m.Data))
// TODO(mdlayher): fine-tune this limit.
if ml > (1024 * 32) {
retu... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SendMessages",
"(",
"messages",
"[",
"]",
"Message",
")",
"(",
"[",
"]",
"Message",
",",
"error",
")",
"{",
"// Wait for any concurrent calls to Execute to finish before proceeding.",
"c",
".",
"mu",
".",
"RLock",
"(",
")",... | // SendMessages sends multiple Messages to netlink. The handling of
// a Header's Length, Sequence and PID fields is the same as when
// calling Send. | [
"SendMessages",
"sends",
"multiple",
"Messages",
"to",
"netlink",
".",
"The",
"handling",
"of",
"a",
"Header",
"s",
"Length",
"Sequence",
"and",
"PID",
"fields",
"is",
"the",
"same",
"as",
"when",
"calling",
"Send",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L144-L175 |
141,384 | mdlayher/netlink | conn.go | Send | func (c *Conn) Send(message Message) (Message, error) {
// Wait for any concurrent calls to Execute to finish before proceeding.
c.mu.RLock()
defer c.mu.RUnlock()
return c.lockedSend(message)
} | go | func (c *Conn) Send(message Message) (Message, error) {
// Wait for any concurrent calls to Execute to finish before proceeding.
c.mu.RLock()
defer c.mu.RUnlock()
return c.lockedSend(message)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Send",
"(",
"message",
"Message",
")",
"(",
"Message",
",",
"error",
")",
"{",
"// Wait for any concurrent calls to Execute to finish before proceeding.",
"c",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"... | // Send sends a single Message to netlink. In most cases, a Header's Length,
// Sequence, and PID fields should be set to 0, so they can be populated
// automatically before the Message is sent. On success, Send returns a copy
// of the Message with all parameters populated, for later validation.
//
// If Header.Leng... | [
"Send",
"sends",
"a",
"single",
"Message",
"to",
"netlink",
".",
"In",
"most",
"cases",
"a",
"Header",
"s",
"Length",
"Sequence",
"and",
"PID",
"fields",
"should",
"be",
"set",
"to",
"0",
"so",
"they",
"can",
"be",
"populated",
"automatically",
"before",
... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L190-L196 |
141,385 | mdlayher/netlink | conn.go | lockedSend | func (c *Conn) lockedSend(message Message) (Message, error) {
ml := nlmsgLength(len(message.Data))
// TODO(mdlayher): fine-tune this limit.
if ml > (1024 * 32) {
return Message{}, errors.New("netlink message data too large")
}
c.fixMsg(&message, ml)
c.debug(func(d *debugger) {
d.debugf(1, "send: %+v", mess... | go | func (c *Conn) lockedSend(message Message) (Message, error) {
ml := nlmsgLength(len(message.Data))
// TODO(mdlayher): fine-tune this limit.
if ml > (1024 * 32) {
return Message{}, errors.New("netlink message data too large")
}
c.fixMsg(&message, ml)
c.debug(func(d *debugger) {
d.debugf(1, "send: %+v", mess... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"lockedSend",
"(",
"message",
"Message",
")",
"(",
"Message",
",",
"error",
")",
"{",
"ml",
":=",
"nlmsgLength",
"(",
"len",
"(",
"message",
".",
"Data",
")",
")",
"\n\n",
"// TODO(mdlayher): fine-tune this limit.",
"if"... | // lockedSend implements Send, but must be called with c.mu acquired for reading.
// We rely on the kernel to deal with concurrent reads and writes to the netlink
// socket itself. | [
"lockedSend",
"implements",
"Send",
"but",
"must",
"be",
"called",
"with",
"c",
".",
"mu",
"acquired",
"for",
"reading",
".",
"We",
"rely",
"on",
"the",
"kernel",
"to",
"deal",
"with",
"concurrent",
"reads",
"and",
"writes",
"to",
"the",
"netlink",
"socket... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L201-L224 |
141,386 | mdlayher/netlink | conn.go | Receive | func (c *Conn) Receive() ([]Message, error) {
// Wait for any concurrent calls to Execute to finish before proceeding.
c.mu.RLock()
defer c.mu.RUnlock()
return c.lockedReceive()
} | go | func (c *Conn) Receive() ([]Message, error) {
// Wait for any concurrent calls to Execute to finish before proceeding.
c.mu.RLock()
defer c.mu.RUnlock()
return c.lockedReceive()
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Receive",
"(",
")",
"(",
"[",
"]",
"Message",
",",
"error",
")",
"{",
"// Wait for any concurrent calls to Execute to finish before proceeding.",
"c",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".... | // Receive receives one or more messages from netlink. Multi-part messages are
// handled transparently and returned as a single slice of Messages, with the
// final empty "multi-part done" message removed.
//
// If any of the messages indicate a netlink error, that error will be returned. | [
"Receive",
"receives",
"one",
"or",
"more",
"messages",
"from",
"netlink",
".",
"Multi",
"-",
"part",
"messages",
"are",
"handled",
"transparently",
"and",
"returned",
"as",
"a",
"single",
"slice",
"of",
"Messages",
"with",
"the",
"final",
"empty",
"multi",
... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L231-L237 |
141,387 | mdlayher/netlink | conn.go | lockedReceive | func (c *Conn) lockedReceive() ([]Message, error) {
msgs, err := c.receive()
if err != nil {
c.debug(func(d *debugger) {
d.debugf(1, "recv: err: %v", err)
})
return nil, err
}
c.debug(func(d *debugger) {
for _, m := range msgs {
d.debugf(1, "recv: %+v", m)
}
})
// When using nltest, it's possib... | go | func (c *Conn) lockedReceive() ([]Message, error) {
msgs, err := c.receive()
if err != nil {
c.debug(func(d *debugger) {
d.debugf(1, "recv: err: %v", err)
})
return nil, err
}
c.debug(func(d *debugger) {
for _, m := range msgs {
d.debugf(1, "recv: %+v", m)
}
})
// When using nltest, it's possib... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"lockedReceive",
"(",
")",
"(",
"[",
"]",
"Message",
",",
"error",
")",
"{",
"msgs",
",",
"err",
":=",
"c",
".",
"receive",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"debug",
"(",
"func",
"("... | // lockedReceive implements Receive, but must be called with c.mu acquired for reading.
// We rely on the kernel to deal with concurrent reads and writes to the netlink
// socket itself. | [
"lockedReceive",
"implements",
"Receive",
"but",
"must",
"be",
"called",
"with",
"c",
".",
"mu",
"acquired",
"for",
"reading",
".",
"We",
"rely",
"on",
"the",
"kernel",
"to",
"deal",
"with",
"concurrent",
"reads",
"and",
"writes",
"to",
"the",
"netlink",
"... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L242-L270 |
141,388 | mdlayher/netlink | conn.go | receive | func (c *Conn) receive() ([]Message, error) {
// NB: All non-nil errors returned from this function *must* be of type
// OpError in order to maintain the appropriate contract with callers of
// this package.
//
// This contract also applies to functions called within this function,
// such as checkMessage.
var ... | go | func (c *Conn) receive() ([]Message, error) {
// NB: All non-nil errors returned from this function *must* be of type
// OpError in order to maintain the appropriate contract with callers of
// this package.
//
// This contract also applies to functions called within this function,
// such as checkMessage.
var ... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"receive",
"(",
")",
"(",
"[",
"]",
"Message",
",",
"error",
")",
"{",
"// NB: All non-nil errors returned from this function *must* be of type",
"// OpError in order to maintain the appropriate contract with callers of",
"// this package.",
... | // receive is the internal implementation of Conn.Receive, which can be called
// recursively to handle multi-part messages. | [
"receive",
"is",
"the",
"internal",
"implementation",
"of",
"Conn",
".",
"Receive",
"which",
"can",
"be",
"called",
"recursively",
"to",
"handle",
"multi",
"-",
"part",
"messages",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L274-L316 |
141,389 | mdlayher/netlink | conn.go | JoinGroup | func (c *Conn) JoinGroup(group uint32) error {
conn, ok := c.sock.(groupJoinLeaver)
if !ok {
return notSupported("join-group")
}
return newOpError("join-group", conn.JoinGroup(group))
} | go | func (c *Conn) JoinGroup(group uint32) error {
conn, ok := c.sock.(groupJoinLeaver)
if !ok {
return notSupported("join-group")
}
return newOpError("join-group", conn.JoinGroup(group))
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"JoinGroup",
"(",
"group",
"uint32",
")",
"error",
"{",
"conn",
",",
"ok",
":=",
"c",
".",
"sock",
".",
"(",
"groupJoinLeaver",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"notSupported",
"(",
"\"",
"\"",
")",
"... | // JoinGroup joins a netlink multicast group by its ID. | [
"JoinGroup",
"joins",
"a",
"netlink",
"multicast",
"group",
"by",
"its",
"ID",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L327-L334 |
141,390 | mdlayher/netlink | conn.go | SetBPF | func (c *Conn) SetBPF(filter []bpf.RawInstruction) error {
conn, ok := c.sock.(bpfSetter)
if !ok {
return notSupported("set-bpf")
}
return newOpError("set-bpf", conn.SetBPF(filter))
} | go | func (c *Conn) SetBPF(filter []bpf.RawInstruction) error {
conn, ok := c.sock.(bpfSetter)
if !ok {
return notSupported("set-bpf")
}
return newOpError("set-bpf", conn.SetBPF(filter))
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SetBPF",
"(",
"filter",
"[",
"]",
"bpf",
".",
"RawInstruction",
")",
"error",
"{",
"conn",
",",
"ok",
":=",
"c",
".",
"sock",
".",
"(",
"bpfSetter",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"notSupported",
"... | // SetBPF attaches an assembled BPF program to a Conn. | [
"SetBPF",
"attaches",
"an",
"assembled",
"BPF",
"program",
"to",
"a",
"Conn",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L354-L361 |
141,391 | mdlayher/netlink | conn.go | RemoveBPF | func (c *Conn) RemoveBPF() error {
conn, ok := c.sock.(bpfSetter)
if !ok {
return notSupported("remove-bpf")
}
return newOpError("remove-bpf", conn.RemoveBPF())
} | go | func (c *Conn) RemoveBPF() error {
conn, ok := c.sock.(bpfSetter)
if !ok {
return notSupported("remove-bpf")
}
return newOpError("remove-bpf", conn.RemoveBPF())
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"RemoveBPF",
"(",
")",
"error",
"{",
"conn",
",",
"ok",
":=",
"c",
".",
"sock",
".",
"(",
"bpfSetter",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"notSupported",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"retu... | // RemoveBPF removes a BPF filter from a Conn. | [
"RemoveBPF",
"removes",
"a",
"BPF",
"filter",
"from",
"a",
"Conn",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L364-L371 |
141,392 | mdlayher/netlink | conn.go | SetDeadline | func (c *Conn) SetDeadline(t time.Time) error {
conn, ok := c.sock.(deadlineSetter)
if !ok {
return notSupported("set-deadline")
}
return newOpError("set-deadline", conn.SetDeadline(t))
} | go | func (c *Conn) SetDeadline(t time.Time) error {
conn, ok := c.sock.(deadlineSetter)
if !ok {
return notSupported("set-deadline")
}
return newOpError("set-deadline", conn.SetDeadline(t))
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"SetDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"conn",
",",
"ok",
":=",
"c",
".",
"sock",
".",
"(",
"deadlineSetter",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"notSupported",
"(",
"\"",
"\""... | // SetDeadline sets the read and write deadlines associated with the connection.
//
// Deadline functionality is only supported on Go 1.12+. Calling this function
// on older versions of Go will result in an error. | [
"SetDeadline",
"sets",
"the",
"read",
"and",
"write",
"deadlines",
"associated",
"with",
"the",
"connection",
".",
"Deadline",
"functionality",
"is",
"only",
"supported",
"on",
"Go",
"1",
".",
"12",
"+",
".",
"Calling",
"this",
"function",
"on",
"older",
"ve... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L385-L392 |
141,393 | mdlayher/netlink | conn.go | fixMsg | func (c *Conn) fixMsg(m *Message, ml int) {
if m.Header.Length == 0 {
m.Header.Length = uint32(nlmsgAlign(ml))
}
if m.Header.Sequence == 0 {
m.Header.Sequence = c.nextSequence()
}
if m.Header.PID == 0 {
m.Header.PID = c.pid
}
} | go | func (c *Conn) fixMsg(m *Message, ml int) {
if m.Header.Length == 0 {
m.Header.Length = uint32(nlmsgAlign(ml))
}
if m.Header.Sequence == 0 {
m.Header.Sequence = c.nextSequence()
}
if m.Header.PID == 0 {
m.Header.PID = c.pid
}
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"fixMsg",
"(",
"m",
"*",
"Message",
",",
"ml",
"int",
")",
"{",
"if",
"m",
".",
"Header",
".",
"Length",
"==",
"0",
"{",
"m",
".",
"Header",
".",
"Length",
"=",
"uint32",
"(",
"nlmsgAlign",
"(",
"ml",
")",
... | // fixMsg updates the fields of m using the logic specified in Send. | [
"fixMsg",
"updates",
"the",
"fields",
"of",
"m",
"using",
"the",
"logic",
"specified",
"in",
"Send",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L513-L525 |
141,394 | mdlayher/netlink | conn.go | Validate | func Validate(request Message, replies []Message) error {
for _, m := range replies {
// Check for mismatched sequence, unless:
// - request had no sequence, meaning we are probably validating
// a multicast reply
if m.Header.Sequence != request.Header.Sequence && request.Header.Sequence != 0 {
return... | go | func Validate(request Message, replies []Message) error {
for _, m := range replies {
// Check for mismatched sequence, unless:
// - request had no sequence, meaning we are probably validating
// a multicast reply
if m.Header.Sequence != request.Header.Sequence && request.Header.Sequence != 0 {
return... | [
"func",
"Validate",
"(",
"request",
"Message",
",",
"replies",
"[",
"]",
"Message",
")",
"error",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"replies",
"{",
"// Check for mismatched sequence, unless:",
"// - request had no sequence, meaning we are probably validating",
... | // Validate validates one or more reply Messages against a request Message,
// ensuring that they contain matching sequence numbers and PIDs. | [
"Validate",
"validates",
"one",
"or",
"more",
"reply",
"Messages",
"against",
"a",
"request",
"Message",
"ensuring",
"that",
"they",
"contain",
"matching",
"sequence",
"numbers",
"and",
"PIDs",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn.go#L535-L555 |
141,395 | mdlayher/netlink | errors.go | IsNotExist | func IsNotExist(err error) bool {
switch err := err.(type) {
case *OpError:
// TODO(mdlayher): more error handling logic?
// Unwrap the inner error and use the stdlib's logic.
return os.IsNotExist(err.Err)
default:
return os.IsNotExist(err)
}
} | go | func IsNotExist(err error) bool {
switch err := err.(type) {
case *OpError:
// TODO(mdlayher): more error handling logic?
// Unwrap the inner error and use the stdlib's logic.
return os.IsNotExist(err.Err)
default:
return os.IsNotExist(err)
}
} | [
"func",
"IsNotExist",
"(",
"err",
"error",
")",
"bool",
"{",
"switch",
"err",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"*",
"OpError",
":",
"// TODO(mdlayher): more error handling logic?",
"// Unwrap the inner error and use the stdlib's logic.",
"return",
"os"... | // IsNotExist determines if an error is produced as the result of querying some
// file, object, resource, etc. which does not exist. Users of this package
// should always use netlink.IsNotExist, rather than os.IsNotExist, when
// checking for specific netlink-related errors.
//
// Errors types created by this packag... | [
"IsNotExist",
"determines",
"if",
"an",
"error",
"is",
"produced",
"as",
"the",
"result",
"of",
"querying",
"some",
"file",
"object",
"resource",
"etc",
".",
"which",
"does",
"not",
"exist",
".",
"Users",
"of",
"this",
"package",
"should",
"always",
"use",
... | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/errors.go#L35-L45 |
141,396 | mdlayher/netlink | errors.go | Temporary | func (e *OpError) Temporary() bool {
if ne, ok := e.Err.(*os.SyscallError); ok {
t, ok := ne.Err.(temporary)
return ok && t.Temporary()
}
t, ok := e.Err.(temporary)
return ok && t.Temporary()
} | go | func (e *OpError) Temporary() bool {
if ne, ok := e.Err.(*os.SyscallError); ok {
t, ok := ne.Err.(temporary)
return ok && t.Temporary()
}
t, ok := e.Err.(temporary)
return ok && t.Temporary()
} | [
"func",
"(",
"e",
"*",
"OpError",
")",
"Temporary",
"(",
")",
"bool",
"{",
"if",
"ne",
",",
"ok",
":=",
"e",
".",
"Err",
".",
"(",
"*",
"os",
".",
"SyscallError",
")",
";",
"ok",
"{",
"t",
",",
"ok",
":=",
"ne",
".",
"Err",
".",
"(",
"tempo... | // Temporary reports whether an operation may succeed if retried. | [
"Temporary",
"reports",
"whether",
"an",
"operation",
"may",
"succeed",
"if",
"retried",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/errors.go#L112-L119 |
141,397 | mdlayher/netlink | netns_linux.go | setThreadNetNS | func setThreadNetNS(fd int) error {
return os.NewSyscallError("setns", unix.Setns(fd, unix.CLONE_NEWNET))
} | go | func setThreadNetNS(fd int) error {
return os.NewSyscallError("setns", unix.Setns(fd, unix.CLONE_NEWNET))
} | [
"func",
"setThreadNetNS",
"(",
"fd",
"int",
")",
"error",
"{",
"return",
"os",
".",
"NewSyscallError",
"(",
"\"",
"\"",
",",
"unix",
".",
"Setns",
"(",
"fd",
",",
"unix",
".",
"CLONE_NEWNET",
")",
")",
"\n",
"}"
] | // setThreadNetNS sets the network namespace of the thread of the current goroutine to
// the namespace described by the user-provided file descriptor. | [
"setThreadNetNS",
"sets",
"the",
"network",
"namespace",
"of",
"the",
"thread",
"of",
"the",
"current",
"goroutine",
"to",
"the",
"namespace",
"described",
"by",
"the",
"user",
"-",
"provided",
"file",
"descriptor",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/netns_linux.go#L25-L27 |
141,398 | mdlayher/netlink | conn_linux.go | dial | func dial(family int, config *Config) (*conn, uint32, error) {
// Prepare sysSocket's internal loop and create the socket.
//
// The conditional is inverted because a zero value of false is desired
// if no config, but it's easier to interpret within this code when the
// value is inverted.
if config == nil {
c... | go | func dial(family int, config *Config) (*conn, uint32, error) {
// Prepare sysSocket's internal loop and create the socket.
//
// The conditional is inverted because a zero value of false is desired
// if no config, but it's easier to interpret within this code when the
// value is inverted.
if config == nil {
c... | [
"func",
"dial",
"(",
"family",
"int",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"conn",
",",
"uint32",
",",
"error",
")",
"{",
"// Prepare sysSocket's internal loop and create the socket.",
"//",
"// The conditional is inverted because a zero value of false is desired",
... | // dial is the entry point for Dial. dial opens a netlink socket using
// system calls, and returns its PID. | [
"dial",
"is",
"the",
"entry",
"point",
"for",
"Dial",
".",
"dial",
"opens",
"a",
"netlink",
"socket",
"using",
"system",
"calls",
"and",
"returns",
"its",
"PID",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L49-L69 |
141,399 | mdlayher/netlink | conn_linux.go | bind | func bind(s socket, config *Config) (*conn, uint32, error) {
if config == nil {
config = &Config{}
}
addr := &unix.SockaddrNetlink{
Family: unix.AF_NETLINK,
Groups: config.Groups,
}
// Socket must be closed in the event of any system call errors, to avoid
// leaking file descriptors.
if err := s.Bind(ad... | go | func bind(s socket, config *Config) (*conn, uint32, error) {
if config == nil {
config = &Config{}
}
addr := &unix.SockaddrNetlink{
Family: unix.AF_NETLINK,
Groups: config.Groups,
}
// Socket must be closed in the event of any system call errors, to avoid
// leaking file descriptors.
if err := s.Bind(ad... | [
"func",
"bind",
"(",
"s",
"socket",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"conn",
",",
"uint32",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"config",
"=",
"&",
"Config",
"{",
"}",
"\n",
"}",
"\n\n",
"addr",
":=",
"&",
"uni... | // bind binds a connection to netlink using the input socket, which may be
// a system call implementation or a mocked one for tests. | [
"bind",
"binds",
"a",
"connection",
"to",
"netlink",
"using",
"the",
"input",
"socket",
"which",
"may",
"be",
"a",
"system",
"call",
"implementation",
"or",
"a",
"mocked",
"one",
"for",
"tests",
"."
] | b540351f6c5108aa445eaa6677010703c7294f8d | https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L73-L103 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.