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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
150,400 | jordan-wright/email | email.go | Read | func (tr trimReader) Read(buf []byte) (int, error) {
n, err := tr.rd.Read(buf)
t := bytes.TrimLeftFunc(buf[:n], unicode.IsSpace)
n = copy(buf, t)
return n, err
} | go | func (tr trimReader) Read(buf []byte) (int, error) {
n, err := tr.rd.Read(buf)
t := bytes.TrimLeftFunc(buf[:n], unicode.IsSpace)
n = copy(buf, t)
return n, err
} | [
"func",
"(",
"tr",
"trimReader",
")",
"Read",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"tr",
".",
"rd",
".",
"Read",
"(",
"buf",
")",
"\n",
"t",
":=",
"bytes",
".",
"TrimLeftFunc",
"(",
"bu... | // Read trims off any unicode whitespace from the originating reader | [
"Read",
"trims",
"off",
"any",
"unicode",
"whitespace",
"from",
"the",
"originating",
"reader"
] | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L74-L79 |
150,401 | jordan-wright/email | email.go | NewEmailFromReader | func NewEmailFromReader(r io.Reader) (*Email, error) {
e := NewEmail()
s := trimReader{rd: r}
tp := textproto.NewReader(bufio.NewReader(s))
// Parse the main headers
hdrs, err := tp.ReadMIMEHeader()
if err != nil {
return e, err
}
// Set the subject, to, cc, bcc, and from
for h, v := range hdrs {
switch {
... | go | func NewEmailFromReader(r io.Reader) (*Email, error) {
e := NewEmail()
s := trimReader{rd: r}
tp := textproto.NewReader(bufio.NewReader(s))
// Parse the main headers
hdrs, err := tp.ReadMIMEHeader()
if err != nil {
return e, err
}
// Set the subject, to, cc, bcc, and from
for h, v := range hdrs {
switch {
... | [
"func",
"NewEmailFromReader",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"Email",
",",
"error",
")",
"{",
"e",
":=",
"NewEmail",
"(",
")",
"\n",
"s",
":=",
"trimReader",
"{",
"rd",
":",
"r",
"}",
"\n",
"tp",
":=",
"textproto",
".",
"NewReader",
... | // NewEmailFromReader reads a stream of bytes from an io.Reader, r,
// and returns an email struct containing the parsed data.
// This function expects the data in RFC 5322 format. | [
"NewEmailFromReader",
"reads",
"a",
"stream",
"of",
"bytes",
"from",
"an",
"io",
".",
"Reader",
"r",
"and",
"returns",
"an",
"email",
"struct",
"containing",
"the",
"parsed",
"data",
".",
"This",
"function",
"expects",
"the",
"data",
"in",
"RFC",
"5322",
"... | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L84-L136 |
150,402 | jordan-wright/email | email.go | Attach | func (e *Email) Attach(r io.Reader, filename string, c string) (a *Attachment, err error) {
var buffer bytes.Buffer
if _, err = io.Copy(&buffer, r); err != nil {
return
}
at := &Attachment{
Filename: filename,
Header: textproto.MIMEHeader{},
Content: buffer.Bytes(),
}
// Get the Content-Type to be used... | go | func (e *Email) Attach(r io.Reader, filename string, c string) (a *Attachment, err error) {
var buffer bytes.Buffer
if _, err = io.Copy(&buffer, r); err != nil {
return
}
at := &Attachment{
Filename: filename,
Header: textproto.MIMEHeader{},
Content: buffer.Bytes(),
}
// Get the Content-Type to be used... | [
"func",
"(",
"e",
"*",
"Email",
")",
"Attach",
"(",
"r",
"io",
".",
"Reader",
",",
"filename",
"string",
",",
"c",
"string",
")",
"(",
"a",
"*",
"Attachment",
",",
"err",
"error",
")",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"if",
"_"... | // Attach is used to attach content from an io.Reader to the email.
// Required parameters include an io.Reader, the desired filename for the attachment, and the Content-Type
// The function will return the created Attachment for reference, as well as nil for the error, if successful. | [
"Attach",
"is",
"used",
"to",
"attach",
"content",
"from",
"an",
"io",
".",
"Reader",
"to",
"the",
"email",
".",
"Required",
"parameters",
"include",
"an",
"io",
".",
"Reader",
"the",
"desired",
"filename",
"for",
"the",
"attachment",
"and",
"the",
"Conten... | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L209-L231 |
150,403 | jordan-wright/email | email.go | AttachFile | func (e *Email) AttachFile(filename string) (a *Attachment, err error) {
f, err := os.Open(filename)
if err != nil {
return
}
defer f.Close()
ct := mime.TypeByExtension(filepath.Ext(filename))
basename := filepath.Base(filename)
return e.Attach(f, basename, ct)
} | go | func (e *Email) AttachFile(filename string) (a *Attachment, err error) {
f, err := os.Open(filename)
if err != nil {
return
}
defer f.Close()
ct := mime.TypeByExtension(filepath.Ext(filename))
basename := filepath.Base(filename)
return e.Attach(f, basename, ct)
} | [
"func",
"(",
"e",
"*",
"Email",
")",
"AttachFile",
"(",
"filename",
"string",
")",
"(",
"a",
"*",
"Attachment",
",",
"err",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // AttachFile is used to attach content to the email.
// It attempts to open the file referenced by filename and, if successful, creates an Attachment.
// This Attachment is then appended to the slice of Email.Attachments.
// The function will then return the Attachment for reference, as well as nil for the error, if s... | [
"AttachFile",
"is",
"used",
"to",
"attach",
"content",
"to",
"the",
"email",
".",
"It",
"attempts",
"to",
"open",
"the",
"file",
"referenced",
"by",
"filename",
"and",
"if",
"successful",
"creates",
"an",
"Attachment",
".",
"This",
"Attachment",
"is",
"then"... | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L237-L247 |
150,404 | jordan-wright/email | email.go | msgHeaders | func (e *Email) msgHeaders() (textproto.MIMEHeader, error) {
res := make(textproto.MIMEHeader, len(e.Headers)+4)
if e.Headers != nil {
for _, h := range []string{"Reply-To", "To", "Cc", "From", "Subject", "Date", "Message-Id", "MIME-Version"} {
if v, ok := e.Headers[h]; ok {
res[h] = v
}
}
}
// Set he... | go | func (e *Email) msgHeaders() (textproto.MIMEHeader, error) {
res := make(textproto.MIMEHeader, len(e.Headers)+4)
if e.Headers != nil {
for _, h := range []string{"Reply-To", "To", "Cc", "From", "Subject", "Date", "Message-Id", "MIME-Version"} {
if v, ok := e.Headers[h]; ok {
res[h] = v
}
}
}
// Set he... | [
"func",
"(",
"e",
"*",
"Email",
")",
"msgHeaders",
"(",
")",
"(",
"textproto",
".",
"MIMEHeader",
",",
"error",
")",
"{",
"res",
":=",
"make",
"(",
"textproto",
".",
"MIMEHeader",
",",
"len",
"(",
"e",
".",
"Headers",
")",
"+",
"4",
")",
"\n",
"i... | // msgHeaders merges the Email's various fields and custom headers together in a
// standards compliant way to create a MIMEHeader to be used in the resulting
// message. It does not alter e.Headers.
//
// "e"'s fields To, Cc, From, Subject will be used unless they are present in
// e.Headers. Unless set in e.Headers, ... | [
"msgHeaders",
"merges",
"the",
"Email",
"s",
"various",
"fields",
"and",
"custom",
"headers",
"together",
"in",
"a",
"standards",
"compliant",
"way",
"to",
"create",
"a",
"MIMEHeader",
"to",
"be",
"used",
"in",
"the",
"resulting",
"message",
".",
"It",
"does... | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L255-L300 |
150,405 | jordan-wright/email | email.go | parseSender | func (e *Email) parseSender() (string, error) {
if e.Sender != "" {
sender, err := mail.ParseAddress(e.Sender)
if err != nil {
return "", err
}
return sender.Address, nil
} else {
from, err := mail.ParseAddress(e.From)
if err != nil {
return "", err
}
return from.Address, nil
}
} | go | func (e *Email) parseSender() (string, error) {
if e.Sender != "" {
sender, err := mail.ParseAddress(e.Sender)
if err != nil {
return "", err
}
return sender.Address, nil
} else {
from, err := mail.ParseAddress(e.From)
if err != nil {
return "", err
}
return from.Address, nil
}
} | [
"func",
"(",
"e",
"*",
"Email",
")",
"parseSender",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"e",
".",
"Sender",
"!=",
"\"",
"\"",
"{",
"sender",
",",
"err",
":=",
"mail",
".",
"ParseAddress",
"(",
"e",
".",
"Sender",
")",
"\n",
"... | // Select and parse an SMTP envelope sender address. Choose Email.Sender if set, or fallback to Email.From. | [
"Select",
"and",
"parse",
"an",
"SMTP",
"envelope",
"sender",
"address",
".",
"Choose",
"Email",
".",
"Sender",
"if",
"set",
"or",
"fallback",
"to",
"Email",
".",
"From",
"."
] | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L439-L453 |
150,406 | jordan-wright/email | email.go | SendWithTLS | func (e *Email) SendWithTLS(addr string, a smtp.Auth, t *tls.Config) error {
// Merge the To, Cc, and Bcc fields
to := make([]string, 0, len(e.To)+len(e.Cc)+len(e.Bcc))
to = append(append(append(to, e.To...), e.Cc...), e.Bcc...)
for i := 0; i < len(to); i++ {
addr, err := mail.ParseAddress(to[i])
if err != nil ... | go | func (e *Email) SendWithTLS(addr string, a smtp.Auth, t *tls.Config) error {
// Merge the To, Cc, and Bcc fields
to := make([]string, 0, len(e.To)+len(e.Cc)+len(e.Bcc))
to = append(append(append(to, e.To...), e.Cc...), e.Bcc...)
for i := 0; i < len(to); i++ {
addr, err := mail.ParseAddress(to[i])
if err != nil ... | [
"func",
"(",
"e",
"*",
"Email",
")",
"SendWithTLS",
"(",
"addr",
"string",
",",
"a",
"smtp",
".",
"Auth",
",",
"t",
"*",
"tls",
".",
"Config",
")",
"error",
"{",
"// Merge the To, Cc, and Bcc fields",
"to",
":=",
"make",
"(",
"[",
"]",
"string",
",",
... | // SendWithTLS sends an email with an optional TLS config.
// This is helpful if you need to connect to a host that is used an untrusted
// certificate. | [
"SendWithTLS",
"sends",
"an",
"email",
"with",
"an",
"optional",
"TLS",
"config",
".",
"This",
"is",
"helpful",
"if",
"you",
"need",
"to",
"connect",
"to",
"a",
"host",
"that",
"is",
"used",
"an",
"untrusted",
"certificate",
"."
] | 3ea4d25e7cf84fe656d10353672a0eba4b919b6d | https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L458-L530 |
150,407 | kata-containers/agent | namespace.go | setupPersistentNs | func setupPersistentNs(namespaceType nsType) (*namespace, error) {
err := os.MkdirAll(persistentNsDir, 0755)
if err != nil {
return nil, err
}
// Create an empty file at the mount point.
nsPath := filepath.Join(persistentNsDir, string(namespaceType))
mountFd, err := os.Create(nsPath)
if err != nil {
retur... | go | func setupPersistentNs(namespaceType nsType) (*namespace, error) {
err := os.MkdirAll(persistentNsDir, 0755)
if err != nil {
return nil, err
}
// Create an empty file at the mount point.
nsPath := filepath.Join(persistentNsDir, string(namespaceType))
mountFd, err := os.Create(nsPath)
if err != nil {
retur... | [
"func",
"setupPersistentNs",
"(",
"namespaceType",
"nsType",
")",
"(",
"*",
"namespace",
",",
"error",
")",
"{",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"persistentNsDir",
",",
"0755",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"e... | // setupPersistentNs creates persistent namespace without switchin to it.
// Note, pid namespaces cannot be persisted. | [
"setupPersistentNs",
"creates",
"persistent",
"namespace",
"without",
"switchin",
"to",
"it",
".",
"Note",
"pid",
"namespaces",
"cannot",
"be",
"persisted",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/namespace.go#L49-L106 |
150,408 | kata-containers/agent | protocols/mockserver/mockserver.go | NewMockServer | func NewMockServer() *grpc.Server {
mock := &mockServer{}
serv := grpc.NewServer()
pb.RegisterAgentServiceServer(serv, mock)
pb.RegisterHealthServer(serv, mock)
return serv
} | go | func NewMockServer() *grpc.Server {
mock := &mockServer{}
serv := grpc.NewServer()
pb.RegisterAgentServiceServer(serv, mock)
pb.RegisterHealthServer(serv, mock)
return serv
} | [
"func",
"NewMockServer",
"(",
")",
"*",
"grpc",
".",
"Server",
"{",
"mock",
":=",
"&",
"mockServer",
"{",
"}",
"\n",
"serv",
":=",
"grpc",
".",
"NewServer",
"(",
")",
"\n",
"pb",
".",
"RegisterAgentServiceServer",
"(",
"serv",
",",
"mock",
")",
"\n",
... | // NewMockServer creates a new gRPC server | [
"NewMockServer",
"creates",
"a",
"new",
"gRPC",
"server"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/mockserver/mockserver.go#L51-L58 |
150,409 | kata-containers/agent | cgroup.go | getAvailableCpusetList | func getAvailableCpusetList(cpusetReq string) (string, error) {
cpusetGuest, err := getCpusetGuest()
if err != nil {
return "", err
}
cpusetListReq, err := parsers.ParseUintList(cpusetReq)
if err != nil {
return "", err
}
cpusetGuestList, err := parsers.ParseUintList(cpusetGuest)
if err != nil {
return... | go | func getAvailableCpusetList(cpusetReq string) (string, error) {
cpusetGuest, err := getCpusetGuest()
if err != nil {
return "", err
}
cpusetListReq, err := parsers.ParseUintList(cpusetReq)
if err != nil {
return "", err
}
cpusetGuestList, err := parsers.ParseUintList(cpusetGuest)
if err != nil {
return... | [
"func",
"getAvailableCpusetList",
"(",
"cpusetReq",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"cpusetGuest",
",",
"err",
":=",
"getCpusetGuest",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n... | // Return the best match for cpuset list in the guest.
// The runtime caller may apply cpuset for specific CPUs in the host.
// The CPUs may not exist on the guest as they are hotplugged based
// on cpu and qouta.
// This function return a working cpuset to apply on the guest. | [
"Return",
"the",
"best",
"match",
"for",
"cpuset",
"list",
"in",
"the",
"guest",
".",
"The",
"runtime",
"caller",
"may",
"apply",
"cpuset",
"for",
"specific",
"CPUs",
"in",
"the",
"host",
".",
"The",
"CPUs",
"may",
"not",
"exist",
"on",
"the",
"guest",
... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/cgroup.go#L32-L65 |
150,410 | kata-containers/agent | protocols/grpc/utils.go | OCItoGRPC | func OCItoGRPC(ociSpec *specs.Spec) (*Spec, error) {
s := &Spec{}
err := copyStruct(s, ociSpec)
return s, err
} | go | func OCItoGRPC(ociSpec *specs.Spec) (*Spec, error) {
s := &Spec{}
err := copyStruct(s, ociSpec)
return s, err
} | [
"func",
"OCItoGRPC",
"(",
"ociSpec",
"*",
"specs",
".",
"Spec",
")",
"(",
"*",
"Spec",
",",
"error",
")",
"{",
"s",
":=",
"&",
"Spec",
"{",
"}",
"\n\n",
"err",
":=",
"copyStruct",
"(",
"s",
",",
"ociSpec",
")",
"\n\n",
"return",
"s",
",",
"err",
... | // OCItoGRPC converts an OCI specification to its gRPC representation | [
"OCItoGRPC",
"converts",
"an",
"OCI",
"specification",
"to",
"its",
"gRPC",
"representation"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L234-L240 |
150,411 | kata-containers/agent | protocols/grpc/utils.go | GRPCtoOCI | func GRPCtoOCI(grpcSpec *Spec) (*specs.Spec, error) {
s := &specs.Spec{}
err := copyStruct(s, grpcSpec)
return s, err
} | go | func GRPCtoOCI(grpcSpec *Spec) (*specs.Spec, error) {
s := &specs.Spec{}
err := copyStruct(s, grpcSpec)
return s, err
} | [
"func",
"GRPCtoOCI",
"(",
"grpcSpec",
"*",
"Spec",
")",
"(",
"*",
"specs",
".",
"Spec",
",",
"error",
")",
"{",
"s",
":=",
"&",
"specs",
".",
"Spec",
"{",
"}",
"\n\n",
"err",
":=",
"copyStruct",
"(",
"s",
",",
"grpcSpec",
")",
"\n\n",
"return",
"... | // GRPCtoOCI converts a gRPC specification back into an OCI representation | [
"GRPCtoOCI",
"converts",
"a",
"gRPC",
"specification",
"back",
"into",
"an",
"OCI",
"representation"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L243-L249 |
150,412 | kata-containers/agent | protocols/grpc/utils.go | ProcessOCItoGRPC | func ProcessOCItoGRPC(ociProcess *specs.Process) (*Process, error) {
s := &Process{}
err := copyStruct(s, ociProcess)
return s, err
} | go | func ProcessOCItoGRPC(ociProcess *specs.Process) (*Process, error) {
s := &Process{}
err := copyStruct(s, ociProcess)
return s, err
} | [
"func",
"ProcessOCItoGRPC",
"(",
"ociProcess",
"*",
"specs",
".",
"Process",
")",
"(",
"*",
"Process",
",",
"error",
")",
"{",
"s",
":=",
"&",
"Process",
"{",
"}",
"\n\n",
"err",
":=",
"copyStruct",
"(",
"s",
",",
"ociProcess",
")",
"\n\n",
"return",
... | // ProcessOCItoGRPC converts an OCI process specification into its gRPC
// representation | [
"ProcessOCItoGRPC",
"converts",
"an",
"OCI",
"process",
"specification",
"into",
"its",
"gRPC",
"representation"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L253-L259 |
150,413 | kata-containers/agent | protocols/grpc/utils.go | ProcessGRPCtoOCI | func ProcessGRPCtoOCI(grpcProcess *Process) (*specs.Process, error) {
s := &specs.Process{}
err := copyStruct(s, grpcProcess)
return s, err
} | go | func ProcessGRPCtoOCI(grpcProcess *Process) (*specs.Process, error) {
s := &specs.Process{}
err := copyStruct(s, grpcProcess)
return s, err
} | [
"func",
"ProcessGRPCtoOCI",
"(",
"grpcProcess",
"*",
"Process",
")",
"(",
"*",
"specs",
".",
"Process",
",",
"error",
")",
"{",
"s",
":=",
"&",
"specs",
".",
"Process",
"{",
"}",
"\n\n",
"err",
":=",
"copyStruct",
"(",
"s",
",",
"grpcProcess",
")",
"... | // ProcessGRPCtoOCI converts a gRPC specification back into an OCI
// representation | [
"ProcessGRPCtoOCI",
"converts",
"a",
"gRPC",
"specification",
"back",
"into",
"an",
"OCI",
"representation"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L263-L269 |
150,414 | kata-containers/agent | protocols/grpc/utils.go | ResourcesOCItoGRPC | func ResourcesOCItoGRPC(ociResources *specs.LinuxResources) (*LinuxResources, error) {
s := &LinuxResources{}
err := copyStruct(s, ociResources)
return s, err
} | go | func ResourcesOCItoGRPC(ociResources *specs.LinuxResources) (*LinuxResources, error) {
s := &LinuxResources{}
err := copyStruct(s, ociResources)
return s, err
} | [
"func",
"ResourcesOCItoGRPC",
"(",
"ociResources",
"*",
"specs",
".",
"LinuxResources",
")",
"(",
"*",
"LinuxResources",
",",
"error",
")",
"{",
"s",
":=",
"&",
"LinuxResources",
"{",
"}",
"\n\n",
"err",
":=",
"copyStruct",
"(",
"s",
",",
"ociResources",
"... | // ResourcesOCItoGRPC converts an OCI LinuxResources specification into its gRPC
// representation | [
"ResourcesOCItoGRPC",
"converts",
"an",
"OCI",
"LinuxResources",
"specification",
"into",
"its",
"gRPC",
"representation"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L273-L279 |
150,415 | kata-containers/agent | protocols/grpc/utils.go | ResourcesGRPCtoOCI | func ResourcesGRPCtoOCI(grpcResources *LinuxResources) (*specs.LinuxResources, error) {
s := &specs.LinuxResources{}
err := copyStruct(s, grpcResources)
return s, err
} | go | func ResourcesGRPCtoOCI(grpcResources *LinuxResources) (*specs.LinuxResources, error) {
s := &specs.LinuxResources{}
err := copyStruct(s, grpcResources)
return s, err
} | [
"func",
"ResourcesGRPCtoOCI",
"(",
"grpcResources",
"*",
"LinuxResources",
")",
"(",
"*",
"specs",
".",
"LinuxResources",
",",
"error",
")",
"{",
"s",
":=",
"&",
"specs",
".",
"LinuxResources",
"{",
"}",
"\n\n",
"err",
":=",
"copyStruct",
"(",
"s",
",",
... | // ResourcesGRPCtoOCI converts an gRPC LinuxResources specification into its OCI
// representation | [
"ResourcesGRPCtoOCI",
"converts",
"an",
"gRPC",
"LinuxResources",
"specification",
"into",
"its",
"OCI",
"representation"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L283-L289 |
150,416 | kata-containers/agent | protocols/client/client.go | heartBeat | func heartBeat(session *yamux.Session) {
if session == nil {
return
}
for {
if session.IsClosed() {
break
}
session.Ping()
// 1 Hz heartbeat
time.Sleep(time.Second)
}
} | go | func heartBeat(session *yamux.Session) {
if session == nil {
return
}
for {
if session.IsClosed() {
break
}
session.Ping()
// 1 Hz heartbeat
time.Sleep(time.Second)
}
} | [
"func",
"heartBeat",
"(",
"session",
"*",
"yamux",
".",
"Session",
")",
"{",
"if",
"session",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"{",
"if",
"session",
".",
"IsClosed",
"(",
")",
"{",
"break",
"\n",
"}",
"\n\n",
"session",
".",
"P... | // This function is meant to run in a go routine since it will send ping
// commands every second. It behaves as a heartbeat to maintain a proper
// communication state with the Yamux server in the agent. | [
"This",
"function",
"is",
"meant",
"to",
"run",
"in",
"a",
"go",
"routine",
"since",
"it",
"will",
"send",
"ping",
"commands",
"every",
"second",
".",
"It",
"behaves",
"as",
"a",
"heartbeat",
"to",
"maintain",
"a",
"proper",
"communication",
"state",
"with... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/client/client.go#L171-L186 |
150,417 | kata-containers/agent | mount.go | ensureDestinationExists | func ensureDestinationExists(source, destination string, fsType string) error {
fileInfo, err := os.Stat(source)
if err != nil {
return grpcStatus.Errorf(codes.Internal, "could not stat source location: %v",
source)
}
if err := createDestinationDir(destination); err != nil {
return grpcStatus.Errorf(codes.I... | go | func ensureDestinationExists(source, destination string, fsType string) error {
fileInfo, err := os.Stat(source)
if err != nil {
return grpcStatus.Errorf(codes.Internal, "could not stat source location: %v",
source)
}
if err := createDestinationDir(destination); err != nil {
return grpcStatus.Errorf(codes.I... | [
"func",
"ensureDestinationExists",
"(",
"source",
",",
"destination",
"string",
",",
"fsType",
"string",
")",
"error",
"{",
"fileInfo",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"source",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcStatus",
... | // ensureDestinationExists will recursively create a given mountpoint. If directories
// are created, their permissions are initialized to mountPerm | [
"ensureDestinationExists",
"will",
"recursively",
"create",
"a",
"given",
"mountpoint",
".",
"If",
"directories",
"are",
"created",
"their",
"permissions",
"are",
"initialized",
"to",
"mountPerm"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L134-L159 |
150,418 | kata-containers/agent | mount.go | virtio9pStorageHandler | func virtio9pStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
return commonStorageHandler(storage)
} | go | func virtio9pStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
return commonStorageHandler(storage)
} | [
"func",
"virtio9pStorageHandler",
"(",
"storage",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"commonStorageHandler",
"(",
"storage",
")",
"\n",
"}"
] | // virtio9pStorageHandler handles the storage for 9p driver. | [
"virtio9pStorageHandler",
"handles",
"the",
"storage",
"for",
"9p",
"driver",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L257-L259 |
150,419 | kata-containers/agent | mount.go | virtioBlkStorageHandler | func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Get the device node path based on the PCI address provided
// in Storage Source
devPath, err := getPCIDeviceName(s, storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | go | func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Get the device node path based on the PCI address provided
// in Storage Source
devPath, err := getPCIDeviceName(s, storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | [
"func",
"virtioBlkStorageHandler",
"(",
"storage",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Get the device node path based on the PCI address provided",
"// in Storage Source",
"devPath",
",",
"err",
":=",
"getPCI... | // virtioBlkStorageHandler handles the storage for blk driver. | [
"virtioBlkStorageHandler",
"handles",
"the",
"storage",
"for",
"blk",
"driver",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L273-L283 |
150,420 | kata-containers/agent | mount.go | virtioSCSIStorageHandler | func virtioSCSIStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Retrieve the device path from SCSI address.
devPath, err := getSCSIDevPath(storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | go | func virtioSCSIStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Retrieve the device path from SCSI address.
devPath, err := getSCSIDevPath(storage.Source)
if err != nil {
return "", err
}
storage.Source = devPath
return commonStorageHandler(storage)
} | [
"func",
"virtioSCSIStorageHandler",
"(",
"storage",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Retrieve the device path from SCSI address.",
"devPath",
",",
"err",
":=",
"getSCSIDevPath",
"(",
"storage",
".",
... | // virtioSCSIStorageHandler handles the storage for scsi driver. | [
"virtioSCSIStorageHandler",
"handles",
"the",
"storage",
"for",
"scsi",
"driver",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L286-L295 |
150,421 | kata-containers/agent | mount.go | mountStorage | func mountStorage(storage pb.Storage) error {
flags, options, err := parseMountFlagsAndOptions(storage.Options)
if err != nil {
return err
}
return mount(storage.Source, storage.MountPoint, storage.Fstype, flags, options)
} | go | func mountStorage(storage pb.Storage) error {
flags, options, err := parseMountFlagsAndOptions(storage.Options)
if err != nil {
return err
}
return mount(storage.Source, storage.MountPoint, storage.Fstype, flags, options)
} | [
"func",
"mountStorage",
"(",
"storage",
"pb",
".",
"Storage",
")",
"error",
"{",
"flags",
",",
"options",
",",
"err",
":=",
"parseMountFlagsAndOptions",
"(",
"storage",
".",
"Options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",... | // mountStorage performs the mount described by the storage structure. | [
"mountStorage",
"performs",
"the",
"mount",
"described",
"by",
"the",
"storage",
"structure",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L307-L314 |
150,422 | kata-containers/agent | mount.go | addStorages | func addStorages(ctx context.Context, storages []*pb.Storage, s *sandbox) ([]string, error) {
span, ctx := trace(ctx, "mount", "addStorages")
span.SetTag("sandbox", s.id)
defer span.Finish()
var mountList []string
for _, storage := range storages {
if storage == nil {
continue
}
devHandler, ok := stora... | go | func addStorages(ctx context.Context, storages []*pb.Storage, s *sandbox) ([]string, error) {
span, ctx := trace(ctx, "mount", "addStorages")
span.SetTag("sandbox", s.id)
defer span.Finish()
var mountList []string
for _, storage := range storages {
if storage == nil {
continue
}
devHandler, ok := stora... | [
"func",
"addStorages",
"(",
"ctx",
"context",
".",
"Context",
",",
"storages",
"[",
"]",
"*",
"pb",
".",
"Storage",
",",
"s",
"*",
"sandbox",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"span",
",",
"ctx",
":=",
"trace",
"(",
"ctx",
","... | // addStorages takes a list of storages passed by the caller, and perform the
// associated operations such as waiting for the device to show up, and mount
// it to a specific location, according to the type of handler chosen, and for
// each storage. | [
"addStorages",
"takes",
"a",
"list",
"of",
"storages",
"passed",
"by",
"the",
"caller",
"and",
"perform",
"the",
"associated",
"operations",
"such",
"as",
"waiting",
"for",
"the",
"device",
"to",
"show",
"up",
"and",
"mount",
"it",
"to",
"a",
"specific",
"... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/mount.go#L320-L356 |
150,423 | kata-containers/agent | config.go | getConfig | func (c *agentConfig) getConfig(cmdLineFile string) error {
if cmdLineFile == "" {
return grpcStatus.Error(codes.FailedPrecondition, "Kernel cmdline file cannot be empty")
}
kernelCmdline, err := ioutil.ReadFile(cmdLineFile)
if err != nil {
return err
}
words := strings.Fields(string(kernelCmdline))
for _,... | go | func (c *agentConfig) getConfig(cmdLineFile string) error {
if cmdLineFile == "" {
return grpcStatus.Error(codes.FailedPrecondition, "Kernel cmdline file cannot be empty")
}
kernelCmdline, err := ioutil.ReadFile(cmdLineFile)
if err != nil {
return err
}
words := strings.Fields(string(kernelCmdline))
for _,... | [
"func",
"(",
"c",
"*",
"agentConfig",
")",
"getConfig",
"(",
"cmdLineFile",
"string",
")",
"error",
"{",
"if",
"cmdLineFile",
"==",
"\"",
"\"",
"{",
"return",
"grpcStatus",
".",
"Error",
"(",
"codes",
".",
"FailedPrecondition",
",",
"\"",
"\"",
")",
"\n"... | //Get the agent configuration from kernel cmdline | [
"Get",
"the",
"agent",
"configuration",
"from",
"kernel",
"cmdline"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/config.go#L44-L65 |
150,424 | kata-containers/agent | config.go | parseCmdlineOption | func (c *agentConfig) parseCmdlineOption(option string) error {
const (
optionPosition = iota
valuePosition
optionSeparator = "="
)
if option == devModeFlag {
crashOnError = true
debug = true
return nil
}
if option == traceModeFlag {
enableTracing(traceModeStatic, defaultTraceType)
return nil
}... | go | func (c *agentConfig) parseCmdlineOption(option string) error {
const (
optionPosition = iota
valuePosition
optionSeparator = "="
)
if option == devModeFlag {
crashOnError = true
debug = true
return nil
}
if option == traceModeFlag {
enableTracing(traceModeStatic, defaultTraceType)
return nil
}... | [
"func",
"(",
"c",
"*",
"agentConfig",
")",
"parseCmdlineOption",
"(",
"option",
"string",
")",
"error",
"{",
"const",
"(",
"optionPosition",
"=",
"iota",
"\n",
"valuePosition",
"\n",
"optionSeparator",
"=",
"\"",
"\"",
"\n",
")",
"\n\n",
"if",
"option",
"=... | //Parse a string that represents a kernel cmdline option | [
"Parse",
"a",
"string",
"that",
"represents",
"a",
"kernel",
"cmdline",
"option"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/config.go#L68-L130 |
150,425 | kata-containers/agent | pkg/uevent/uevent.go | NewReaderCloser | func NewReaderCloser() (io.ReadCloser, error) {
nl := unix.SockaddrNetlink{
Family: unix.AF_NETLINK,
// Passing Pid as 0 here allows the kernel to take care of assigning
// it. This allows multiple netlink sockets to be used.
Pid: uint32(0),
Groups: 1,
}
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOC... | go | func NewReaderCloser() (io.ReadCloser, error) {
nl := unix.SockaddrNetlink{
Family: unix.AF_NETLINK,
// Passing Pid as 0 here allows the kernel to take care of assigning
// it. This allows multiple netlink sockets to be used.
Pid: uint32(0),
Groups: 1,
}
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOC... | [
"func",
"NewReaderCloser",
"(",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"nl",
":=",
"unix",
".",
"SockaddrNetlink",
"{",
"Family",
":",
"unix",
".",
"AF_NETLINK",
",",
"// Passing Pid as 0 here allows the kernel to take care of assigning",
"// it.... | // NewReaderCloser returns an io.ReadCloser handle for uevent. | [
"NewReaderCloser",
"returns",
"an",
"io",
".",
"ReadCloser",
"handle",
"for",
"uevent",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L36-L55 |
150,426 | kata-containers/agent | pkg/uevent/uevent.go | Read | func (r *ReaderCloser) Read(p []byte) (int, error) {
count, err := unix.Read(r.fd, p)
if count < 0 && err != nil {
count = 0
}
return count, err
} | go | func (r *ReaderCloser) Read(p []byte) (int, error) {
count, err := unix.Read(r.fd, p)
if count < 0 && err != nil {
count = 0
}
return count, err
} | [
"func",
"(",
"r",
"*",
"ReaderCloser",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"unix",
".",
"Read",
"(",
"r",
".",
"fd",
",",
"p",
")",
"\n",
"if",
"count",
"<",
"0",
"&&"... | // Read implements reading function for uevent. | [
"Read",
"implements",
"reading",
"function",
"for",
"uevent",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L58-L64 |
150,427 | kata-containers/agent | pkg/uevent/uevent.go | NewHandler | func NewHandler() (*Handler, error) {
rdCloser, err := NewReaderCloser()
if err != nil {
return nil, err
}
return &Handler{
readerCloser: rdCloser,
bufioReader: bufio.NewReader(rdCloser),
}, nil
} | go | func NewHandler() (*Handler, error) {
rdCloser, err := NewReaderCloser()
if err != nil {
return nil, err
}
return &Handler{
readerCloser: rdCloser,
bufioReader: bufio.NewReader(rdCloser),
}, nil
} | [
"func",
"NewHandler",
"(",
")",
"(",
"*",
"Handler",
",",
"error",
")",
"{",
"rdCloser",
",",
"err",
":=",
"NewReaderCloser",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"Handler",
"... | // NewHandler returns a uevent handler. | [
"NewHandler",
"returns",
"a",
"uevent",
"handler",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L88-L98 |
150,428 | kata-containers/agent | pkg/uevent/uevent.go | Read | func (h *Handler) Read() (*Uevent, error) {
uEv := &Uevent{}
// Read header first.
header, err := h.bufioReader.ReadString(paramDelim)
if err != nil {
return nil, err
}
// Fill uevent header.
uEv.Header = header
exitLoop := false
// Read every parameter as "key=value".
for !exitLoop {
keyValue, err :=... | go | func (h *Handler) Read() (*Uevent, error) {
uEv := &Uevent{}
// Read header first.
header, err := h.bufioReader.ReadString(paramDelim)
if err != nil {
return nil, err
}
// Fill uevent header.
uEv.Header = header
exitLoop := false
// Read every parameter as "key=value".
for !exitLoop {
keyValue, err :=... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"Read",
"(",
")",
"(",
"*",
"Uevent",
",",
"error",
")",
"{",
"uEv",
":=",
"&",
"Uevent",
"{",
"}",
"\n\n",
"// Read header first.",
"header",
",",
"err",
":=",
"h",
".",
"bufioReader",
".",
"ReadString",
"(",
... | // Read blocks and returns the next uevent when available. | [
"Read",
"blocks",
"and",
"returns",
"the",
"next",
"uevent",
"when",
"available",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/pkg/uevent/uevent.go#L101-L154 |
150,429 | kata-containers/agent | channel.go | Write | func (yw yamuxWriter) Write(bytes []byte) (int, error) {
message := string(bytes)
l := len(message)
// yamux messages are all warnings and errors
agentLog.WithField("component", "yamux").Warn(message)
return l, nil
} | go | func (yw yamuxWriter) Write(bytes []byte) (int, error) {
message := string(bytes)
l := len(message)
// yamux messages are all warnings and errors
agentLog.WithField("component", "yamux").Warn(message)
return l, nil
} | [
"func",
"(",
"yw",
"yamuxWriter",
")",
"Write",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"message",
":=",
"string",
"(",
"bytes",
")",
"\n\n",
"l",
":=",
"len",
"(",
"message",
")",
"\n\n",
"// yamux messages are all war... | // Write implements the Writer interface for the yamuxWriter. | [
"Write",
"implements",
"the",
"Writer",
"interface",
"for",
"the",
"yamuxWriter",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/channel.go#L226-L235 |
150,430 | kata-containers/agent | channel.go | isAFVSockSupported | func isAFVSockSupported() (bool, error) {
// Driver path for virtio-vsock
sysVsockPath := "/sys/bus/virtio/drivers/vmw_vsock_virtio_transport/"
files, err := ioutil.ReadDir(sysVsockPath)
// This should not happen for a hypervisor with vsock driver
if err != nil {
return false, err
}
// standard driver files... | go | func isAFVSockSupported() (bool, error) {
// Driver path for virtio-vsock
sysVsockPath := "/sys/bus/virtio/drivers/vmw_vsock_virtio_transport/"
files, err := ioutil.ReadDir(sysVsockPath)
// This should not happen for a hypervisor with vsock driver
if err != nil {
return false, err
}
// standard driver files... | [
"func",
"isAFVSockSupported",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// Driver path for virtio-vsock",
"sysVsockPath",
":=",
"\"",
"\"",
"\n\n",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"sysVsockPath",
")",
"\n\n",
"// This should not h... | // isAFVSockSupported checks if vsock channel is used by the runtime
// by checking for devices under the vhost-vsock driver path.
// It returns true if a device is found for the vhost-vsock driver. | [
"isAFVSockSupported",
"checks",
"if",
"vsock",
"channel",
"is",
"used",
"by",
"the",
"runtime",
"by",
"checking",
"for",
"devices",
"under",
"the",
"vhost",
"-",
"vsock",
"driver",
"path",
".",
"It",
"returns",
"true",
"if",
"a",
"device",
"is",
"found",
"... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/channel.go#L274-L316 |
150,431 | kata-containers/agent | agent.go | closePostExitFDs | func (p *process) closePostExitFDs() {
if p.termMaster != nil {
p.termMaster.Close()
}
if p.stdin != nil {
p.stdin.Close()
}
if p.stdout != nil {
p.stdout.Close()
}
if p.stderr != nil {
p.stderr.Close()
}
if p.epoller != nil {
p.epoller.sockR.Close()
}
} | go | func (p *process) closePostExitFDs() {
if p.termMaster != nil {
p.termMaster.Close()
}
if p.stdin != nil {
p.stdin.Close()
}
if p.stdout != nil {
p.stdout.Close()
}
if p.stderr != nil {
p.stderr.Close()
}
if p.epoller != nil {
p.epoller.sockR.Close()
}
} | [
"func",
"(",
"p",
"*",
"process",
")",
"closePostExitFDs",
"(",
")",
"{",
"if",
"p",
".",
"termMaster",
"!=",
"nil",
"{",
"p",
".",
"termMaster",
".",
"Close",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"p",
".",
"stdin",
"!=",
"nil",
"{",
"p",
".",
"s... | // This is the list of file descriptors we can properly close after the process
// has exited. These are the remaining file descriptors that we have opened and
// are no longer needed. | [
"This",
"is",
"the",
"list",
"of",
"file",
"descriptors",
"we",
"can",
"properly",
"close",
"after",
"the",
"process",
"has",
"exited",
".",
"These",
"are",
"the",
"remaining",
"file",
"descriptors",
"that",
"we",
"have",
"opened",
"and",
"are",
"no",
"lon... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L204-L224 |
150,432 | kata-containers/agent | agent.go | setSandboxStorage | func (s *sandbox) setSandboxStorage(path string) bool {
if _, ok := s.storages[path]; !ok {
sbs := &sandboxStorage{refCount: 1}
s.storages[path] = sbs
return true
}
sbs := s.storages[path]
sbs.refCount++
return false
} | go | func (s *sandbox) setSandboxStorage(path string) bool {
if _, ok := s.storages[path]; !ok {
sbs := &sandboxStorage{refCount: 1}
s.storages[path] = sbs
return true
}
sbs := s.storages[path]
sbs.refCount++
return false
} | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"setSandboxStorage",
"(",
"path",
"string",
")",
"bool",
"{",
"if",
"_",
",",
"ok",
":=",
"s",
".",
"storages",
"[",
"path",
"]",
";",
"!",
"ok",
"{",
"sbs",
":=",
"&",
"sandboxStorage",
"{",
"refCount",
":",
... | // setSandboxStorage sets the sandbox level reference
// counter for the sandbox storage.
// This method also returns a boolean to let
// callers know if the storage already existed or not.
// It will return true if storage is new.
//
// It's assumed that caller is calling this method after
// acquiring a lock on sandb... | [
"setSandboxStorage",
"sets",
"the",
"sandbox",
"level",
"reference",
"counter",
"for",
"the",
"sandbox",
"storage",
".",
"This",
"method",
"also",
"returns",
"a",
"boolean",
"to",
"let",
"callers",
"know",
"if",
"the",
"storage",
"already",
"existed",
"or",
"n... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L296-L305 |
150,433 | kata-containers/agent | agent.go | scanGuestHooks | func (s *sandbox) scanGuestHooks(guestHookPath string) {
span, _ := s.trace("scanGuestHooks")
span.SetTag("guest-hook-path", guestHookPath)
defer span.Finish()
fieldLogger := agentLog.WithField("oci-hook-path", guestHookPath)
fieldLogger.Info("Scanning guest filesystem for OCI hooks")
s.guestHooks.Prestart = fi... | go | func (s *sandbox) scanGuestHooks(guestHookPath string) {
span, _ := s.trace("scanGuestHooks")
span.SetTag("guest-hook-path", guestHookPath)
defer span.Finish()
fieldLogger := agentLog.WithField("oci-hook-path", guestHookPath)
fieldLogger.Info("Scanning guest filesystem for OCI hooks")
s.guestHooks.Prestart = fi... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"scanGuestHooks",
"(",
"guestHookPath",
"string",
")",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"guestHookPath",
")",
"\n",
"defe... | // scanGuestHooks will search the given guestHookPath
// for any OCI hooks | [
"scanGuestHooks",
"will",
"search",
"the",
"given",
"guestHookPath",
"for",
"any",
"OCI",
"hooks"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L309-L326 |
150,434 | kata-containers/agent | agent.go | addGuestHooks | func (s *sandbox) addGuestHooks(spec *specs.Spec) {
span, _ := s.trace("addGuestHooks")
defer span.Finish()
if spec == nil {
return
}
if spec.Hooks == nil {
spec.Hooks = &specs.Hooks{}
}
spec.Hooks.Prestart = append(spec.Hooks.Prestart, s.guestHooks.Prestart...)
spec.Hooks.Poststart = append(spec.Hooks.P... | go | func (s *sandbox) addGuestHooks(spec *specs.Spec) {
span, _ := s.trace("addGuestHooks")
defer span.Finish()
if spec == nil {
return
}
if spec.Hooks == nil {
spec.Hooks = &specs.Hooks{}
}
spec.Hooks.Prestart = append(spec.Hooks.Prestart, s.guestHooks.Prestart...)
spec.Hooks.Poststart = append(spec.Hooks.P... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"addGuestHooks",
"(",
"spec",
"*",
"specs",
".",
"Spec",
")",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"if",
"spec",
"==... | // addGuestHooks will add any guest OCI hooks that were
// found to the OCI spec | [
"addGuestHooks",
"will",
"add",
"any",
"guest",
"OCI",
"hooks",
"that",
"were",
"found",
"to",
"the",
"OCI",
"spec"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L330-L345 |
150,435 | kata-containers/agent | agent.go | unSetSandboxStorage | func (s *sandbox) unSetSandboxStorage(path string) (bool, error) {
span, _ := s.trace("unSetSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if sbs, ok := s.storages[path]; ok {
sbs.refCount--
// If this sandbox storage is not used by any container
// then remove it's reference
if sbs.refCoun... | go | func (s *sandbox) unSetSandboxStorage(path string) (bool, error) {
span, _ := s.trace("unSetSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if sbs, ok := s.storages[path]; ok {
sbs.refCount--
// If this sandbox storage is not used by any container
// then remove it's reference
if sbs.refCoun... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"unSetSandboxStorage",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"... | // unSetSandboxStorage will decrement the sandbox storage
// reference counter. If there aren't any containers using
// that sandbox storage, this method will remove the
// storage reference from the sandbox and return 'true, nil' to
// let the caller know that they can clean up the storage
// related directories by ca... | [
"unSetSandboxStorage",
"will",
"decrement",
"the",
"sandbox",
"storage",
"reference",
"counter",
".",
"If",
"there",
"aren",
"t",
"any",
"containers",
"using",
"that",
"sandbox",
"storage",
"this",
"method",
"will",
"remove",
"the",
"storage",
"reference",
"from",... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L356-L372 |
150,436 | kata-containers/agent | agent.go | removeSandboxStorage | func (s *sandbox) removeSandboxStorage(path string) error {
span, _ := s.trace("removeSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
err := removeMounts([]string{path})
if err != nil {
return grpcStatus.Errorf(codes.Unknown, "Unable to unmount sandbox storage path %s", path)
}
err = os.RemoveA... | go | func (s *sandbox) removeSandboxStorage(path string) error {
span, _ := s.trace("removeSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
err := removeMounts([]string{path})
if err != nil {
return grpcStatus.Errorf(codes.Unknown, "Unable to unmount sandbox storage path %s", path)
}
err = os.RemoveA... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"removeSandboxStorage",
"(",
"path",
"string",
")",
"error",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"defer... | // removeSandboxStorage removes the sandbox storage if no
// containers are using that storage.
//
// It's assumed that caller is calling this method after
// acquiring a lock on sandbox. | [
"removeSandboxStorage",
"removes",
"the",
"sandbox",
"storage",
"if",
"no",
"containers",
"are",
"using",
"that",
"storage",
".",
"It",
"s",
"assumed",
"that",
"caller",
"is",
"calling",
"this",
"method",
"after",
"acquiring",
"a",
"lock",
"on",
"sandbox",
"."... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L379-L393 |
150,437 | kata-containers/agent | agent.go | unsetAndRemoveSandboxStorage | func (s *sandbox) unsetAndRemoveSandboxStorage(path string) error {
span, _ := s.trace("unsetAndRemoveSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if _, ok := s.storages[path]; ok {
removeSbs, err := s.unSetSandboxStorage(path)
if err != nil {
return err
}
if removeSbs {
if err := ... | go | func (s *sandbox) unsetAndRemoveSandboxStorage(path string) error {
span, _ := s.trace("unsetAndRemoveSandboxStorage")
span.SetTag("path", path)
defer span.Finish()
if _, ok := s.storages[path]; ok {
removeSbs, err := s.unSetSandboxStorage(path)
if err != nil {
return err
}
if removeSbs {
if err := ... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"unsetAndRemoveSandboxStorage",
"(",
"path",
"string",
")",
"error",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"span",
".",
"SetTag",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
... | // unsetAndRemoveSandboxStorage unsets the storage from sandbox
// and if there are no containers using this storage it will
// remove it from the sandbox.
//
// It's assumed that caller is calling this method after
// acquiring a lock on sandbox. | [
"unsetAndRemoveSandboxStorage",
"unsets",
"the",
"storage",
"from",
"sandbox",
"and",
"if",
"there",
"are",
"no",
"containers",
"using",
"this",
"storage",
"it",
"will",
"remove",
"it",
"from",
"the",
"sandbox",
".",
"It",
"s",
"assumed",
"that",
"caller",
"is... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L401-L421 |
150,438 | kata-containers/agent | agent.go | signalHandlerLoop | func (s *sandbox) signalHandlerLoop(sigCh chan os.Signal) {
for sig := range sigCh {
logger := agentLog.WithField("signal", sig)
if sig == unix.SIGCHLD {
if err := s.subreaper.reap(); err != nil {
logger.WithError(err).Error("failed to reap")
continue
}
}
nativeSignal, ok := sig.(syscall.Signal... | go | func (s *sandbox) signalHandlerLoop(sigCh chan os.Signal) {
for sig := range sigCh {
logger := agentLog.WithField("signal", sig)
if sig == unix.SIGCHLD {
if err := s.subreaper.reap(); err != nil {
logger.WithError(err).Error("failed to reap")
continue
}
}
nativeSignal, ok := sig.(syscall.Signal... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"signalHandlerLoop",
"(",
"sigCh",
"chan",
"os",
".",
"Signal",
")",
"{",
"for",
"sig",
":=",
"range",
"sigCh",
"{",
"logger",
":=",
"agentLog",
".",
"WithField",
"(",
"\"",
"\"",
",",
"sig",
")",
"\n\n",
"if",
... | // This loop is meant to be run inside a separate Go routine. | [
"This",
"loop",
"is",
"meant",
"to",
"be",
"run",
"inside",
"a",
"separate",
"Go",
"routine",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L749-L780 |
150,439 | kata-containers/agent | agent.go | getMemory | func getMemory() (string, error) {
bytes, err := ioutil.ReadFile(meminfo)
if err != nil {
return "", err
}
lines := string(bytes)
for _, line := range strings.Split(lines, "\n") {
if !strings.HasPrefix(line, "MemTotal") {
continue
}
expectedFields := 2
fields := strings.Split(line, ":")
count :=... | go | func getMemory() (string, error) {
bytes, err := ioutil.ReadFile(meminfo)
if err != nil {
return "", err
}
lines := string(bytes)
for _, line := range strings.Split(lines, "\n") {
if !strings.HasPrefix(line, "MemTotal") {
continue
}
expectedFields := 2
fields := strings.Split(line, ":")
count :=... | [
"func",
"getMemory",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"meminfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"lines",
":... | // getMemory returns a string containing the total amount of memory reported
// by the kernel. The string includes a suffix denoting the units the memory
// is measured in. | [
"getMemory",
"returns",
"a",
"string",
"containing",
"the",
"total",
"amount",
"of",
"memory",
"reported",
"by",
"the",
"kernel",
".",
"The",
"string",
"includes",
"a",
"suffix",
"denoting",
"the",
"units",
"the",
"memory",
"is",
"measured",
"in",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L807-L839 |
150,440 | kata-containers/agent | agent.go | announce | func announce() error {
announceFields, err := getAnnounceFields()
if err != nil {
return err
}
if os.Getpid() == 1 {
fields := formatFields(agentFields)
extraFields := formatFields(announceFields)
fields = append(fields, extraFields...)
fmt.Printf("announce: %s\n", strings.Join(fields, ","))
} else {... | go | func announce() error {
announceFields, err := getAnnounceFields()
if err != nil {
return err
}
if os.Getpid() == 1 {
fields := formatFields(agentFields)
extraFields := formatFields(announceFields)
fields = append(fields, extraFields...)
fmt.Printf("announce: %s\n", strings.Join(fields, ","))
} else {... | [
"func",
"announce",
"(",
")",
"error",
"{",
"announceFields",
",",
"err",
":=",
"getAnnounceFields",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"os",
".",
"Getpid",
"(",
")",
"==",
"1",
"{",
"fields",
"... | // announce logs details of the agents version and capabilities. | [
"announce",
"logs",
"details",
"of",
"the",
"agents",
"version",
"and",
"capabilities",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L884-L902 |
150,441 | kata-containers/agent | agent.go | initAgentAsInit | func initAgentAsInit() error {
if err := generalMount(); err != nil {
return err
}
if err := cgroupsMount(); err != nil {
return err
}
if err := syscall.Unlink("/dev/ptmx"); err != nil {
return err
}
if err := syscall.Symlink("/dev/pts/ptmx", "/dev/ptmx"); err != nil {
return err
}
syscall.Setsid()
sy... | go | func initAgentAsInit() error {
if err := generalMount(); err != nil {
return err
}
if err := cgroupsMount(); err != nil {
return err
}
if err := syscall.Unlink("/dev/ptmx"); err != nil {
return err
}
if err := syscall.Symlink("/dev/pts/ptmx", "/dev/ptmx"); err != nil {
return err
}
syscall.Setsid()
sy... | [
"func",
"initAgentAsInit",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"generalMount",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cgroupsMount",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"er... | // initAgentAsInit will do the initializations such as setting up the rootfs
// when this agent has been run as the init process. | [
"initAgentAsInit",
"will",
"do",
"the",
"initializations",
"such",
"as",
"setting",
"up",
"the",
"rootfs",
"when",
"this",
"agent",
"has",
"been",
"run",
"as",
"the",
"init",
"process",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/agent.go#L1201-L1219 |
150,442 | kata-containers/agent | oci.go | findHooks | func findHooks(guestHookPath, hookType string) (hooksFound []specs.Hook) {
hooksPath := path.Join(guestHookPath, hookType)
files, err := ioutil.ReadDir(hooksPath)
if err != nil {
agentLog.WithError(err).WithField("oci-hook-type", hookType).Info("Skipping hook type")
return
}
for _, file := range files {
na... | go | func findHooks(guestHookPath, hookType string) (hooksFound []specs.Hook) {
hooksPath := path.Join(guestHookPath, hookType)
files, err := ioutil.ReadDir(hooksPath)
if err != nil {
agentLog.WithError(err).WithField("oci-hook-type", hookType).Info("Skipping hook type")
return
}
for _, file := range files {
na... | [
"func",
"findHooks",
"(",
"guestHookPath",
",",
"hookType",
"string",
")",
"(",
"hooksFound",
"[",
"]",
"specs",
".",
"Hook",
")",
"{",
"hooksPath",
":=",
"path",
".",
"Join",
"(",
"guestHookPath",
",",
"hookType",
")",
"\n\n",
"files",
",",
"err",
":=",... | // findHooks searches guestHookPath for any OCI hooks for a given hookType | [
"findHooks",
"searches",
"guestHookPath",
"for",
"any",
"OCI",
"hooks",
"for",
"a",
"given",
"hookType"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/oci.go#L83-L112 |
150,443 | kata-containers/agent | tracing.go | trace | func trace(ctx context.Context, subsystem, name string) (opentracing.Span, context.Context) {
span, ctx := opentracing.StartSpanFromContext(ctx, name)
span.SetTag("subsystem", subsystem)
// This is slightly confusing: when tracing is disabled, trace spans
// are still created - but the tracer used is a NOP. There... | go | func trace(ctx context.Context, subsystem, name string) (opentracing.Span, context.Context) {
span, ctx := opentracing.StartSpanFromContext(ctx, name)
span.SetTag("subsystem", subsystem)
// This is slightly confusing: when tracing is disabled, trace spans
// are still created - but the tracer used is a NOP. There... | [
"func",
"trace",
"(",
"ctx",
"context",
".",
"Context",
",",
"subsystem",
",",
"name",
"string",
")",
"(",
"opentracing",
".",
"Span",
",",
"context",
".",
"Context",
")",
"{",
"span",
",",
"ctx",
":=",
"opentracing",
".",
"StartSpanFromContext",
"(",
"c... | // trace creates a new tracing span based on the specified contex, subsystem
// and name. | [
"trace",
"creates",
"a",
"new",
"tracing",
"span",
"based",
"on",
"the",
"specified",
"contex",
"subsystem",
"and",
"name",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/tracing.go#L135-L148 |
150,444 | kata-containers/agent | grpc.go | handleError | func handleError(wait bool, err error) error {
if !wait {
agentLog.WithError(err).Error()
}
return err
} | go | func handleError(wait bool, err error) error {
if !wait {
agentLog.WithError(err).Error()
}
return err
} | [
"func",
"handleError",
"(",
"wait",
"bool",
",",
"err",
"error",
")",
"error",
"{",
"if",
"!",
"wait",
"{",
"agentLog",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // handleError will log the specified error if wait is false | [
"handleError",
"will",
"log",
"the",
"specified",
"error",
"if",
"wait",
"is",
"false"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L83-L89 |
150,445 | kata-containers/agent | grpc.go | onlineResources | func onlineResources(resource onlineResource, nbResources int32) (uint32, error) {
files, err := ioutil.ReadDir(resource.sysfsOnlinePath)
if err != nil {
return 0, err
}
var count uint32
for _, file := range files {
matched, err := regexp.MatchString(resource.regexpPattern, file.Name())
if err != nil {
r... | go | func onlineResources(resource onlineResource, nbResources int32) (uint32, error) {
files, err := ioutil.ReadDir(resource.sysfsOnlinePath)
if err != nil {
return 0, err
}
var count uint32
for _, file := range files {
matched, err := regexp.MatchString(resource.regexpPattern, file.Name())
if err != nil {
r... | [
"func",
"onlineResources",
"(",
"resource",
"onlineResource",
",",
"nbResources",
"int32",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"resource",
".",
"sysfsOnlinePath",
")",
"\n",
"if",
"err",
"!=... | // Online resources, nbResources specifies the maximum number of resources to online.
// If nbResources is <= 0 then there is no limit and all resources are connected.
// Returns the number of resources connected. | [
"Online",
"resources",
"nbResources",
"specifies",
"the",
"maximum",
"number",
"of",
"resources",
"to",
"online",
".",
"If",
"nbResources",
"is",
"<",
"=",
"0",
"then",
"there",
"is",
"no",
"limit",
"and",
"all",
"resources",
"are",
"connected",
".",
"Return... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L94-L131 |
150,446 | kata-containers/agent | grpc.go | updateCpusetPath | func updateCpusetPath(cgroupPath string, newCpuset string, cookies cookie) error {
// Each cpuset cgroup parent MUST BE updated with the actual number of vCPUs.
//Start to update from cgroup system root.
cgroupParentPath := cgroupCpusetPath
cpusetGuest, err := getCpusetGuest()
if err != nil {
return err
}
//... | go | func updateCpusetPath(cgroupPath string, newCpuset string, cookies cookie) error {
// Each cpuset cgroup parent MUST BE updated with the actual number of vCPUs.
//Start to update from cgroup system root.
cgroupParentPath := cgroupCpusetPath
cpusetGuest, err := getCpusetGuest()
if err != nil {
return err
}
//... | [
"func",
"updateCpusetPath",
"(",
"cgroupPath",
"string",
",",
"newCpuset",
"string",
",",
"cookies",
"cookie",
")",
"error",
"{",
"// Each cpuset cgroup parent MUST BE updated with the actual number of vCPUs.",
"//Start to update from cgroup system root.",
"cgroupParentPath",
":=",... | // updates a cpuset cgroups path visiting each sub-directory in cgroupPath parent and writing
// the maximal set of cpus in cpuset.cpus file, finally the cgroupPath is updated with the requsted
//value.
// cookies are used for performance reasons in order to
// don't update a cgroup twice. | [
"updates",
"a",
"cpuset",
"cgroups",
"path",
"visiting",
"each",
"sub",
"-",
"directory",
"in",
"cgroupPath",
"parent",
"and",
"writing",
"the",
"maximal",
"set",
"of",
"cpus",
"in",
"cpuset",
".",
"cpus",
"file",
"finally",
"the",
"cgroupPath",
"is",
"updat... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L170-L221 |
150,447 | kata-containers/agent | grpc.go | execProcess | func (a *agentGRPC) execProcess(ctr *container, proc *process, createContainer bool) (err error) {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
// This lock is very import... | go | func (a *agentGRPC) execProcess(ctr *container, proc *process, createContainer bool) (err error) {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
// This lock is very import... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"execProcess",
"(",
"ctr",
"*",
"container",
",",
"proc",
"*",
"process",
",",
"createContainer",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"if",
"ctr",
"==",
"nil",
"{",
"return",
"grpcStatus",
".",
"Error",
... | // Shared function between CreateContainer and ExecProcess, because those expect
// a process to be run. | [
"Shared",
"function",
"between",
"CreateContainer",
"and",
"ExecProcess",
"because",
"those",
"expect",
"a",
"process",
"to",
"be",
"run",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L392-L433 |
150,448 | kata-containers/agent | grpc.go | postExecProcess | func (a *agentGRPC) postExecProcess(ctr *container, proc *process) error {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
defer proc.closePostStartFDs()
// Setup terminal ... | go | func (a *agentGRPC) postExecProcess(ctr *container, proc *process) error {
if ctr == nil {
return grpcStatus.Error(codes.InvalidArgument, "Container cannot be nil")
}
if proc == nil {
return grpcStatus.Error(codes.InvalidArgument, "Process cannot be nil")
}
defer proc.closePostStartFDs()
// Setup terminal ... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"postExecProcess",
"(",
"ctr",
"*",
"container",
",",
"proc",
"*",
"process",
")",
"error",
"{",
"if",
"ctr",
"==",
"nil",
"{",
"return",
"grpcStatus",
".",
"Error",
"(",
"codes",
".",
"InvalidArgument",
",",
"\... | // Shared function between CreateContainer and ExecProcess, because those expect
// the console to be properly setup after the process has been started. | [
"Shared",
"function",
"between",
"CreateContainer",
"and",
"ExecProcess",
"because",
"those",
"expect",
"the",
"console",
"to",
"be",
"properly",
"setup",
"after",
"the",
"process",
"has",
"been",
"started",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L437-L476 |
150,449 | kata-containers/agent | grpc.go | updateContainerConfigNamespaces | func (a *agentGRPC) updateContainerConfigNamespaces(config *configs.Config, ctr *container) {
var ipcNs, utsNs bool
for idx, ns := range config.Namespaces {
if ns.Type == configs.NEWIPC {
config.Namespaces[idx].Path = a.sandbox.sharedIPCNs.path
ipcNs = true
}
if ns.Type == configs.NEWUTS {
config.Nam... | go | func (a *agentGRPC) updateContainerConfigNamespaces(config *configs.Config, ctr *container) {
var ipcNs, utsNs bool
for idx, ns := range config.Namespaces {
if ns.Type == configs.NEWIPC {
config.Namespaces[idx].Path = a.sandbox.sharedIPCNs.path
ipcNs = true
}
if ns.Type == configs.NEWUTS {
config.Nam... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"updateContainerConfigNamespaces",
"(",
"config",
"*",
"configs",
".",
"Config",
",",
"ctr",
"*",
"container",
")",
"{",
"var",
"ipcNs",
",",
"utsNs",
"bool",
"\n\n",
"for",
"idx",
",",
"ns",
":=",
"range",
"confi... | // This function updates the container namespaces configuration based on the
// sandbox information. When the sandbox is created, it can be setup in a way
// that all containers will share some specific namespaces. This is the agent
// responsibility to create those namespaces so that they can be shared across
// sever... | [
"This",
"function",
"updates",
"the",
"container",
"namespaces",
"configuration",
"based",
"on",
"the",
"sandbox",
"information",
".",
"When",
"the",
"sandbox",
"is",
"created",
"it",
"can",
"be",
"setup",
"in",
"a",
"way",
"that",
"all",
"containers",
"will",... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L489-L538 |
150,450 | kata-containers/agent | grpc.go | rollbackFailingContainerCreation | func (a *agentGRPC) rollbackFailingContainerCreation(ctr *container) {
if ctr.container != nil {
ctr.container.Destroy()
}
a.sandbox.deleteContainer(ctr.id)
if err := removeMounts(ctr.mounts); err != nil {
agentLog.WithError(err).Error("rollback failed removeMounts()")
}
} | go | func (a *agentGRPC) rollbackFailingContainerCreation(ctr *container) {
if ctr.container != nil {
ctr.container.Destroy()
}
a.sandbox.deleteContainer(ctr.id)
if err := removeMounts(ctr.mounts); err != nil {
agentLog.WithError(err).Error("rollback failed removeMounts()")
}
} | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"rollbackFailingContainerCreation",
"(",
"ctr",
"*",
"container",
")",
"{",
"if",
"ctr",
".",
"container",
"!=",
"nil",
"{",
"ctr",
".",
"container",
".",
"Destroy",
"(",
")",
"\n",
"}",
"\n\n",
"a",
".",
"sandb... | // rollbackFailingContainerCreation rolls back important steps that might have
// been performed before the container creation failed.
// - Destroy the container created by libcontainer
// - Delete the container from the agent internal map
// - Unmount all mounts related to this container | [
"rollbackFailingContainerCreation",
"rolls",
"back",
"important",
"steps",
"that",
"might",
"have",
"been",
"performed",
"before",
"the",
"container",
"creation",
"failed",
".",
"-",
"Destroy",
"the",
"container",
"created",
"by",
"libcontainer",
"-",
"Delete",
"the... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L563-L573 |
150,451 | kata-containers/agent | grpc.go | applyNetworkSysctls | func (a *agentGRPC) applyNetworkSysctls(ociSpec *specs.Spec) error {
sysctls := ociSpec.Linux.Sysctl
for key, value := range sysctls {
if isNetworkSysctl(key) {
if err := writeSystemProperty(key, value); err != nil {
return err
}
delete(sysctls, key)
}
}
ociSpec.Linux.Sysctl = sysctls
return nil
... | go | func (a *agentGRPC) applyNetworkSysctls(ociSpec *specs.Spec) error {
sysctls := ociSpec.Linux.Sysctl
for key, value := range sysctls {
if isNetworkSysctl(key) {
if err := writeSystemProperty(key, value); err != nil {
return err
}
delete(sysctls, key)
}
}
ociSpec.Linux.Sysctl = sysctls
return nil
... | [
"func",
"(",
"a",
"*",
"agentGRPC",
")",
"applyNetworkSysctls",
"(",
"ociSpec",
"*",
"specs",
".",
"Spec",
")",
"error",
"{",
"sysctls",
":=",
"ociSpec",
".",
"Linux",
".",
"Sysctl",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"sysctls",
"{",
"if"... | // libcontainer checks if the container is running in a separate network namespace
// before applying the network related sysctls. If it sees that the network namespace of the container
// is the same as the "host", it errors out. Since we do no create a new net namespace inside the guest,
// libcontainer would error o... | [
"libcontainer",
"checks",
"if",
"the",
"container",
"is",
"running",
"in",
"a",
"separate",
"network",
"namespace",
"before",
"applying",
"the",
"network",
"related",
"sysctls",
".",
"If",
"it",
"sees",
"that",
"the",
"network",
"namespace",
"of",
"the",
"cont... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L730-L743 |
150,452 | kata-containers/agent | grpc.go | isSignalHandled | func isSignalHandled(pid int, signum syscall.Signal) bool {
var sigMask uint64 = 1 << (uint(signum) - 1)
procFile := fmt.Sprintf("/proc/%d/status", pid)
file, err := os.Open(procFile)
if err != nil {
agentLog.WithField("procFile", procFile).Warn("Open proc file failed")
return false
}
defer file.Close()
sca... | go | func isSignalHandled(pid int, signum syscall.Signal) bool {
var sigMask uint64 = 1 << (uint(signum) - 1)
procFile := fmt.Sprintf("/proc/%d/status", pid)
file, err := os.Open(procFile)
if err != nil {
agentLog.WithField("procFile", procFile).Warn("Open proc file failed")
return false
}
defer file.Close()
sca... | [
"func",
"isSignalHandled",
"(",
"pid",
"int",
",",
"signum",
"syscall",
".",
"Signal",
")",
"bool",
"{",
"var",
"sigMask",
"uint64",
"=",
"1",
"<<",
"(",
"uint",
"(",
"signum",
")",
"-",
"1",
")",
"\n",
"procFile",
":=",
"fmt",
".",
"Sprintf",
"(",
... | // Check is the container process installed the
// handler for specific signal. | [
"Check",
"is",
"the",
"container",
"process",
"installed",
"the",
"handler",
"for",
"specific",
"signal",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/grpc.go#L951-L980 |
150,453 | kata-containers/agent | device.go | findSCSIDisk | func findSCSIDisk(scsiPath string) (string, error) {
files, err := ioutil.ReadDir(scsiPath)
if err != nil {
return "", err
}
if len(files) != 1 {
return "", grpcStatus.Errorf(codes.Internal,
"Expecting a single SCSI device, found %v",
files)
}
return files[0].Name(), nil
} | go | func findSCSIDisk(scsiPath string) (string, error) {
files, err := ioutil.ReadDir(scsiPath)
if err != nil {
return "", err
}
if len(files) != 1 {
return "", grpcStatus.Errorf(codes.Internal,
"Expecting a single SCSI device, found %v",
files)
}
return files[0].Name(), nil
} | [
"func",
"findSCSIDisk",
"(",
"scsiPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"scsiPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"... | // findSCSIDisk finds the SCSI disk name associated with the given SCSI path.
// This approach eliminates the need to predict the disk name on the host side,
// but we do need to rescan SCSI bus for this. | [
"findSCSIDisk",
"finds",
"the",
"SCSI",
"disk",
"name",
"associated",
"with",
"the",
"given",
"SCSI",
"path",
".",
"This",
"approach",
"eliminates",
"the",
"need",
"to",
"predict",
"the",
"disk",
"name",
"on",
"the",
"host",
"side",
"but",
"we",
"do",
"nee... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/device.go#L383-L396 |
150,454 | kata-containers/agent | device.go | getSCSIDevPath | func getSCSIDevPath(scsiAddr string) (string, error) {
if err := scanSCSIBus(scsiAddr); err != nil {
return "", err
}
devPath := filepath.Join(scsiDiskPrefix+scsiAddr, scsiDiskSuffix)
checkUevent := func(uEv *uevent.Uevent) bool {
devSubPath := filepath.Join(scsiHostChannel+scsiAddr, scsiBlockSuffix)
return... | go | func getSCSIDevPath(scsiAddr string) (string, error) {
if err := scanSCSIBus(scsiAddr); err != nil {
return "", err
}
devPath := filepath.Join(scsiDiskPrefix+scsiAddr, scsiDiskSuffix)
checkUevent := func(uEv *uevent.Uevent) bool {
devSubPath := filepath.Join(scsiHostChannel+scsiAddr, scsiBlockSuffix)
return... | [
"func",
"getSCSIDevPath",
"(",
"scsiAddr",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"scanSCSIBus",
"(",
"scsiAddr",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"devPath",
":=... | // getSCSIDevPath scans SCSI bus looking for the provided SCSI address, then
// it waits for the SCSI disk to become available and returns the device path
// associated with the disk. | [
"getSCSIDevPath",
"scans",
"SCSI",
"bus",
"looking",
"for",
"the",
"provided",
"SCSI",
"address",
"then",
"it",
"waits",
"for",
"the",
"SCSI",
"disk",
"to",
"become",
"available",
"and",
"returns",
"the",
"device",
"path",
"associated",
"with",
"the",
"disk",
... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/device.go#L401-L423 |
150,455 | kata-containers/agent | network.go | updateInterface | func (s *sandbox) updateInterface(netHandle *netlink.Handle, iface *types.Interface) (resultingIfc *types.Interface, err error) {
if iface == nil {
return nil, errNoIF
}
s.network.ifacesLock.Lock()
defer s.network.ifacesLock.Unlock()
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE... | go | func (s *sandbox) updateInterface(netHandle *netlink.Handle, iface *types.Interface) (resultingIfc *types.Interface, err error) {
if iface == nil {
return nil, errNoIF
}
s.network.ifacesLock.Lock()
defer s.network.ifacesLock.Unlock()
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"updateInterface",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
",",
"iface",
"*",
"types",
".",
"Interface",
")",
"(",
"resultingIfc",
"*",
"types",
".",
"Interface",
",",
"err",
"error",
")",
"{",
"if",
"ifa... | // updateInterface will update an existing interface with the values provided in the types.Interface. It will identify the
// existing interface via MAC address and will return the state of the interface once the function completes as well an any
// errors observed. | [
"updateInterface",
"will",
"update",
"an",
"existing",
"interface",
"with",
"the",
"values",
"provided",
"in",
"the",
"types",
".",
"Interface",
".",
"It",
"will",
"identify",
"the",
"existing",
"interface",
"via",
"MAC",
"address",
"and",
"will",
"return",
"t... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L199-L277 |
150,456 | kata-containers/agent | network.go | getInterface | func getInterface(netHandle *netlink.Handle, link netlink.Link) (*types.Interface, error) {
if netHandle == nil {
return nil, errNoHandle
}
if link == nil {
return nil, errNoLink
}
var ifc types.Interface
linkAttrs := link.Attrs()
ifc.Name = linkAttrs.Name
ifc.Mtu = uint64(linkAttrs.MTU)
ifc.HwAddr = lin... | go | func getInterface(netHandle *netlink.Handle, link netlink.Link) (*types.Interface, error) {
if netHandle == nil {
return nil, errNoHandle
}
if link == nil {
return nil, errNoLink
}
var ifc types.Interface
linkAttrs := link.Attrs()
ifc.Name = linkAttrs.Name
ifc.Mtu = uint64(linkAttrs.MTU)
ifc.HwAddr = lin... | [
"func",
"getInterface",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
",",
"link",
"netlink",
".",
"Link",
")",
"(",
"*",
"types",
".",
"Interface",
",",
"error",
")",
"{",
"if",
"netHandle",
"==",
"nil",
"{",
"return",
"nil",
",",
"errNoHandle",
"\... | // getInterface will retrieve interface details from the provided link | [
"getInterface",
"will",
"retrieve",
"interface",
"details",
"from",
"the",
"provided",
"link"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L280-L310 |
150,457 | kata-containers/agent | network.go | updateRoutes | func (s *sandbox) updateRoutes(netHandle *netlink.Handle, requestedRoutes *pb.Routes) (resultingRoutes *pb.Routes, err error) {
if requestedRoutes == nil {
return nil, errNoRoutes
}
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netH... | go | func (s *sandbox) updateRoutes(netHandle *netlink.Handle, requestedRoutes *pb.Routes) (resultingRoutes *pb.Routes, err error) {
if requestedRoutes == nil {
return nil, errNoRoutes
}
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netH... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"updateRoutes",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
",",
"requestedRoutes",
"*",
"pb",
".",
"Routes",
")",
"(",
"resultingRoutes",
"*",
"pb",
".",
"Routes",
",",
"err",
"error",
")",
"{",
"if",
"reque... | //updateRoutes will take requestedRoutes and create netlink routes, with a goal of creating a final
// state which matches the requested routes. In doing this, preesxisting non-loopback routes will be
// removed from the network. If an error occurs, this function returns the list of routes in
// gRPC-route format at ... | [
"updateRoutes",
"will",
"take",
"requestedRoutes",
"and",
"create",
"netlink",
"routes",
"with",
"a",
"goal",
"of",
"creating",
"a",
"final",
"state",
"which",
"matches",
"the",
"requested",
"routes",
".",
"In",
"doing",
"this",
"preesxisting",
"non",
"-",
"lo... | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L375-L435 |
150,458 | kata-containers/agent | network.go | getCurrentRoutes | func getCurrentRoutes(netHandle *netlink.Handle) (*pb.Routes, error) {
var err error
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netHandle.Delete()
}
var routes pb.Routes
finalRouteList, err := netHandle.RouteList(nil, netlink.FA... | go | func getCurrentRoutes(netHandle *netlink.Handle) (*pb.Routes, error) {
var err error
if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netHandle.Delete()
}
var routes pb.Routes
finalRouteList, err := netHandle.RouteList(nil, netlink.FA... | [
"func",
"getCurrentRoutes",
"(",
"netHandle",
"*",
"netlink",
".",
"Handle",
")",
"(",
"*",
"pb",
".",
"Routes",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"if",
"netHandle",
"==",
"nil",
"{",
"netHandle",
",",
"err",
"=",
"netlink",
".",
"... | //getCurrentRoutes is a helper to gather existing routes in gRPC protocol format | [
"getCurrentRoutes",
"is",
"a",
"helper",
"to",
"gather",
"existing",
"routes",
"in",
"gRPC",
"protocol",
"format"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L442-L485 |
150,459 | kata-containers/agent | network.go | handleLocalhost | func (s *sandbox) handleLocalhost() error {
span, _ := s.trace("handleLocalhost")
defer span.Finish()
// If not running as the init daemon, there is nothing to do as the
// localhost interface will already exist.
if os.Getpid() != 1 {
return nil
}
lo, err := netlink.LinkByName("lo")
if err != nil {
return... | go | func (s *sandbox) handleLocalhost() error {
span, _ := s.trace("handleLocalhost")
defer span.Finish()
// If not running as the init daemon, there is nothing to do as the
// localhost interface will already exist.
if os.Getpid() != 1 {
return nil
}
lo, err := netlink.LinkByName("lo")
if err != nil {
return... | [
"func",
"(",
"s",
"*",
"sandbox",
")",
"handleLocalhost",
"(",
")",
"error",
"{",
"span",
",",
"_",
":=",
"s",
".",
"trace",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"// If not running as the init daemon, there is nothi... | // Bring up localhost network interface. | [
"Bring",
"up",
"localhost",
"network",
"interface",
"."
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/network.go#L605-L621 |
150,460 | kata-containers/agent | reaper.go | run | func (r *agentReaper) run(c *exec.Cmd) error {
exitCodeCh, err := r.start(c)
if err != nil {
return fmt.Errorf("reaper: Could not start process: %v", err)
}
_, err = r.wait(exitCodeCh, (*reaperOSProcess)(c.Process))
return err
} | go | func (r *agentReaper) run(c *exec.Cmd) error {
exitCodeCh, err := r.start(c)
if err != nil {
return fmt.Errorf("reaper: Could not start process: %v", err)
}
_, err = r.wait(exitCodeCh, (*reaperOSProcess)(c.Process))
return err
} | [
"func",
"(",
"r",
"*",
"agentReaper",
")",
"run",
"(",
"c",
"*",
"exec",
".",
"Cmd",
")",
"error",
"{",
"exitCodeCh",
",",
"err",
":=",
"r",
".",
"start",
"(",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // run runs the exec command and waits for it, returns once the command
// has been reaped | [
"run",
"runs",
"the",
"exec",
"command",
"and",
"waits",
"for",
"it",
"returns",
"once",
"the",
"command",
"has",
"been",
"reaped"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/reaper.go#L228-L235 |
150,461 | kata-containers/agent | reaper.go | combinedOutput | func (r *agentReaper) combinedOutput(c *exec.Cmd) ([]byte, error) {
if c.Stdout != nil {
return nil, errors.New("reaper: Stdout already set")
}
if c.Stderr != nil {
return nil, errors.New("reaper: Stderr already set")
}
var b bytes.Buffer
c.Stdout = &b
c.Stderr = &b
err := r.run(c)
return b.Bytes(), err
} | go | func (r *agentReaper) combinedOutput(c *exec.Cmd) ([]byte, error) {
if c.Stdout != nil {
return nil, errors.New("reaper: Stdout already set")
}
if c.Stderr != nil {
return nil, errors.New("reaper: Stderr already set")
}
var b bytes.Buffer
c.Stdout = &b
c.Stderr = &b
err := r.run(c)
return b.Bytes(), err
} | [
"func",
"(",
"r",
"*",
"agentReaper",
")",
"combinedOutput",
"(",
"c",
"*",
"exec",
".",
"Cmd",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"c",
".",
"Stdout",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"... | // combinedOutput combines command's stdout and stderr in one buffer,
// returns once the command has been reaped | [
"combinedOutput",
"combines",
"command",
"s",
"stdout",
"and",
"stderr",
"in",
"one",
"buffer",
"returns",
"once",
"the",
"command",
"has",
"been",
"reaped"
] | 629f90f9ff2065509d46192325e6409bdaacef79 | https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/reaper.go#L239-L252 |
150,462 | mattn/go-oci8 | statement.go | Close | func (stmt *OCI8Stmt) Close() error {
if stmt.closed {
return nil
}
stmt.closed = true
C.OCIHandleFree(unsafe.Pointer(stmt.stmt), C.OCI_HTYPE_STMT)
stmt.stmt = nil
stmt.pbind = nil
return nil
} | go | func (stmt *OCI8Stmt) Close() error {
if stmt.closed {
return nil
}
stmt.closed = true
C.OCIHandleFree(unsafe.Pointer(stmt.stmt), C.OCI_HTYPE_STMT)
stmt.stmt = nil
stmt.pbind = nil
return nil
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"stmt",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"stmt",
".",
"closed",
"=",
"true",
"\n\n",
"C",
".",
"OCIHandleFree",
"(",
"unsafe",
".",
"Pointer",
"(... | // Close closes the statement | [
"Close",
"closes",
"the",
"statement"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L19-L31 |
150,463 | mattn/go-oci8 | statement.go | NumInput | func (stmt *OCI8Stmt) NumInput() int {
var bindCount C.ub4 // number of bind position
_, err := stmt.ociAttrGet(unsafe.Pointer(&bindCount), C.OCI_ATTR_BIND_COUNT)
if err != nil {
return -1
}
return int(bindCount)
} | go | func (stmt *OCI8Stmt) NumInput() int {
var bindCount C.ub4 // number of bind position
_, err := stmt.ociAttrGet(unsafe.Pointer(&bindCount), C.OCI_ATTR_BIND_COUNT)
if err != nil {
return -1
}
return int(bindCount)
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"NumInput",
"(",
")",
"int",
"{",
"var",
"bindCount",
"C",
".",
"ub4",
"// number of bind position",
"\n",
"_",
",",
"err",
":=",
"stmt",
".",
"ociAttrGet",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"bindCount",
... | // NumInput returns the number of input | [
"NumInput",
"returns",
"the",
"number",
"of",
"input"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L34-L42 |
150,464 | mattn/go-oci8 | statement.go | Query | func (stmt *OCI8Stmt) Query(args []driver.Value) (rows driver.Rows, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.query(context.Background(), list, false)
} | go | func (stmt *OCI8Stmt) Query(args []driver.Value) (rows driver.Rows, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.query(context.Background(), list, false)
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"Query",
"(",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"rows",
"driver",
".",
"Rows",
",",
"err",
"error",
")",
"{",
"list",
":=",
"make",
"(",
"[",
"]",
"namedValue",
",",
"len",
"(",
"args",... | // Query runs a query | [
"Query",
"runs",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L310-L319 |
150,465 | mattn/go-oci8 | statement.go | getRowid | func (stmt *OCI8Stmt) getRowid() (string, error) {
rowidP, _, err := stmt.conn.ociDescriptorAlloc(C.OCI_DTYPE_ROWID, 0)
if err != nil {
return "", err
}
// OCI_ATTR_ROWID returns the ROWID descriptor allocated with OCIDescriptorAlloc()
_, err = stmt.ociAttrGet(*rowidP, C.OCI_ATTR_ROWID)
if err != nil {
retur... | go | func (stmt *OCI8Stmt) getRowid() (string, error) {
rowidP, _, err := stmt.conn.ociDescriptorAlloc(C.OCI_DTYPE_ROWID, 0)
if err != nil {
return "", err
}
// OCI_ATTR_ROWID returns the ROWID descriptor allocated with OCIDescriptorAlloc()
_, err = stmt.ociAttrGet(*rowidP, C.OCI_ATTR_ROWID)
if err != nil {
retur... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"getRowid",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"rowidP",
",",
"_",
",",
"err",
":=",
"stmt",
".",
"conn",
".",
"ociDescriptorAlloc",
"(",
"C",
".",
"OCI_DTYPE_ROWID",
",",
"0",
")",
"\n",
"if... | // getRowid returns the rowid | [
"getRowid",
"returns",
"the",
"rowid"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L579-L601 |
150,466 | mattn/go-oci8 | statement.go | rowsAffected | func (stmt *OCI8Stmt) rowsAffected() (int64, error) {
var rowCount C.ub4 // Number of rows processed so far after SELECT statements. For INSERT, UPDATE, and DELETE statements, it is the number of rows processed by the most recent statement. The default value is 1.
_, err := stmt.ociAttrGet(unsafe.Pointer(&rowCount), ... | go | func (stmt *OCI8Stmt) rowsAffected() (int64, error) {
var rowCount C.ub4 // Number of rows processed so far after SELECT statements. For INSERT, UPDATE, and DELETE statements, it is the number of rows processed by the most recent statement. The default value is 1.
_, err := stmt.ociAttrGet(unsafe.Pointer(&rowCount), ... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"rowsAffected",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"rowCount",
"C",
".",
"ub4",
"// Number of rows processed so far after SELECT statements. For INSERT, UPDATE, and DELETE statements, it is the number of rows proc... | // rowsAffected returns the number of rows affected | [
"rowsAffected",
"returns",
"the",
"number",
"of",
"rows",
"affected"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L604-L611 |
150,467 | mattn/go-oci8 | statement.go | Exec | func (stmt *OCI8Stmt) Exec(args []driver.Value) (r driver.Result, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.exec(context.Background(), list)
} | go | func (stmt *OCI8Stmt) Exec(args []driver.Value) (r driver.Result, err error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return stmt.exec(context.Background(), list)
} | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"Exec",
"(",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"r",
"driver",
".",
"Result",
",",
"err",
"error",
")",
"{",
"list",
":=",
"make",
"(",
"[",
"]",
"namedValue",
",",
"len",
"(",
"args",
... | // Exec runs an exec query | [
"Exec",
"runs",
"an",
"exec",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L614-L623 |
150,468 | mattn/go-oci8 | statement.go | exec | func (stmt *OCI8Stmt) exec(ctx context.Context, args []namedValue) (driver.Result, error) {
binds, err := stmt.bind(ctx, args)
if err != nil {
return nil, err
}
defer freeBinds(binds)
mode := C.ub4(C.OCI_DEFAULT)
if stmt.conn.inTransaction == false {
mode = mode | C.OCI_COMMIT_ON_SUCCESS
}
done := make(c... | go | func (stmt *OCI8Stmt) exec(ctx context.Context, args []namedValue) (driver.Result, error) {
binds, err := stmt.bind(ctx, args)
if err != nil {
return nil, err
}
defer freeBinds(binds)
mode := C.ub4(C.OCI_DEFAULT)
if stmt.conn.inTransaction == false {
mode = mode | C.OCI_COMMIT_ON_SUCCESS
}
done := make(c... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"[",
"]",
"namedValue",
")",
"(",
"driver",
".",
"Result",
",",
"error",
")",
"{",
"binds",
",",
"err",
":=",
"stmt",
".",
"bind",
"(",
"ctx",
... | // exec runs an exec query | [
"exec",
"runs",
"an",
"exec",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L626-L662 |
150,469 | mattn/go-oci8 | statement.go | ociParamGet | func (stmt *OCI8Stmt) ociParamGet(position C.ub4) (*C.OCIParam, error) {
var paramTemp *C.OCIParam
param := ¶mTemp
result := C.OCIParamGet(
unsafe.Pointer(stmt.stmt), // A statement handle or describe handle
C.OCI_HTYPE_STMT, // Handle type: OCI_HTYPE_STMT, for a state... | go | func (stmt *OCI8Stmt) ociParamGet(position C.ub4) (*C.OCIParam, error) {
var paramTemp *C.OCIParam
param := ¶mTemp
result := C.OCIParamGet(
unsafe.Pointer(stmt.stmt), // A statement handle or describe handle
C.OCI_HTYPE_STMT, // Handle type: OCI_HTYPE_STMT, for a state... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociParamGet",
"(",
"position",
"C",
".",
"ub4",
")",
"(",
"*",
"C",
".",
"OCIParam",
",",
"error",
")",
"{",
"var",
"paramTemp",
"*",
"C",
".",
"OCIParam",
"\n",
"param",
":=",
"&",
"paramTemp",
"\n\n",
"... | // ociParamGet calls OCIParamGet then returns OCIParam and error.
// OCIDescriptorFree must be called on returned OCIParam. | [
"ociParamGet",
"calls",
"OCIParamGet",
"then",
"returns",
"OCIParam",
"and",
"error",
".",
"OCIDescriptorFree",
"must",
"be",
"called",
"on",
"returned",
"OCIParam",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L817-L835 |
150,470 | mattn/go-oci8 | statement.go | ociAttrGet | func (stmt *OCI8Stmt) ociAttrGet(value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(stmt.stmt), // Pointer to a handle type
C.OCI_HTYPE_STMT, // The handle type: OCI_HTYPE_STMT, for a statement handle
value, // Pointer ... | go | func (stmt *OCI8Stmt) ociAttrGet(value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(stmt.stmt), // Pointer to a handle type
C.OCI_HTYPE_STMT, // The handle type: OCI_HTYPE_STMT, for a statement handle
value, // Pointer ... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociAttrGet",
"(",
"value",
"unsafe",
".",
"Pointer",
",",
"attributeType",
"C",
".",
"ub4",
")",
"(",
"C",
".",
"ub4",
",",
"error",
")",
"{",
"var",
"size",
"C",
".",
"ub4",
"\n\n",
"result",
":=",
"C",
... | // ociAttrGet calls OCIAttrGet with OCIStmt then returns attribute size and error.
// The attribute value is stored into passed value. | [
"ociAttrGet",
"calls",
"OCIAttrGet",
"with",
"OCIStmt",
"then",
"returns",
"attribute",
"size",
"and",
"error",
".",
"The",
"attribute",
"value",
"is",
"stored",
"into",
"passed",
"value",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L839-L852 |
150,471 | mattn/go-oci8 | statement.go | ociBindByName | func (stmt *OCI8Stmt) ociBindByName(name []byte, bind *oci8Bind) error {
result := C.OCIBindByName(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deall... | go | func (stmt *OCI8Stmt) ociBindByName(name []byte, bind *oci8Bind) error {
result := C.OCIBindByName(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deall... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociBindByName",
"(",
"name",
"[",
"]",
"byte",
",",
"bind",
"*",
"oci8Bind",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIBindByName",
"(",
"stmt",
".",
"stmt",
",",
"// The statement handle",
"&",
"bind",
... | // ociBindByName calls OCIBindByName, then returns bind handle and error. | [
"ociBindByName",
"calls",
"OCIBindByName",
"then",
"returns",
"bind",
"handle",
"and",
"error",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L855-L874 |
150,472 | mattn/go-oci8 | statement.go | ociBindByPos | func (stmt *OCI8Stmt) ociBindByPos(position C.ub4, bind *oci8Bind) error {
result := C.OCIBindByPos(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deal... | go | func (stmt *OCI8Stmt) ociBindByPos(position C.ub4, bind *oci8Bind) error {
result := C.OCIBindByPos(
stmt.stmt, // The statement handle
&bind.bindHandle, // The bind handle that is implicitly allocated by this call. The handle is freed implicitly when the statement handle is deal... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociBindByPos",
"(",
"position",
"C",
".",
"ub4",
",",
"bind",
"*",
"oci8Bind",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIBindByPos",
"(",
"stmt",
".",
"stmt",
",",
"// The statement handle",
"&",
"bind",... | // ociBindByPos calls OCIBindByPos, then returns bind handle and error. | [
"ociBindByPos",
"calls",
"OCIBindByPos",
"then",
"returns",
"bind",
"handle",
"and",
"error",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L877-L895 |
150,473 | mattn/go-oci8 | statement.go | ociStmtExecute | func (stmt *OCI8Stmt) ociStmtExecute(iters C.ub4, mode C.ub4) error {
result := C.OCIStmtExecute(
stmt.conn.svc, // Service context handle
stmt.stmt, // A statement handle
stmt.conn.errHandle, // An error handle
iters, // For non-SELECT statements, the number of times this stateme... | go | func (stmt *OCI8Stmt) ociStmtExecute(iters C.ub4, mode C.ub4) error {
result := C.OCIStmtExecute(
stmt.conn.svc, // Service context handle
stmt.stmt, // A statement handle
stmt.conn.errHandle, // An error handle
iters, // For non-SELECT statements, the number of times this stateme... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociStmtExecute",
"(",
"iters",
"C",
".",
"ub4",
",",
"mode",
"C",
".",
"ub4",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIStmtExecute",
"(",
"stmt",
".",
"conn",
".",
"svc",
",",
"// Service context hand... | // ociStmtExecute calls OCIStmtExecute | [
"ociStmtExecute",
"calls",
"OCIStmtExecute"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L898-L911 |
150,474 | mattn/go-oci8 | statement.go | ociBreak | func (stmt *OCI8Stmt) ociBreak(ctx context.Context, done chan struct{}) {
select {
case <-done:
case <-ctx.Done():
// select again to avoid race condition if both are done
select {
case <-done:
default:
result := C.OCIBreak(
unsafe.Pointer(stmt.conn.svc), // The service context handle or the server co... | go | func (stmt *OCI8Stmt) ociBreak(ctx context.Context, done chan struct{}) {
select {
case <-done:
case <-ctx.Done():
// select again to avoid race condition if both are done
select {
case <-done:
default:
result := C.OCIBreak(
unsafe.Pointer(stmt.conn.svc), // The service context handle or the server co... | [
"func",
"(",
"stmt",
"*",
"OCI8Stmt",
")",
"ociBreak",
"(",
"ctx",
"context",
".",
"Context",
",",
"done",
"chan",
"struct",
"{",
"}",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"// select a... | // ociBreak calls OCIBreak if ctx.Done is finished before done chan is closed | [
"ociBreak",
"calls",
"OCIBreak",
"if",
"ctx",
".",
"Done",
"is",
"finished",
"before",
"done",
"chan",
"is",
"closed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/statement.go#L914-L932 |
150,475 | mattn/go-oci8 | connection.go | Exec | func (conn *OCI8Conn) Exec(query string, args []driver.Value) (driver.Result, error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return conn.exec(context.Background(), query, list)
} | go | func (conn *OCI8Conn) Exec(query string, args []driver.Value) (driver.Result, error) {
list := make([]namedValue, len(args))
for i, v := range args {
list[i] = namedValue{
Ordinal: i + 1,
Value: v,
}
}
return conn.exec(context.Background(), query, list)
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Exec",
"(",
"query",
"string",
",",
"args",
"[",
"]",
"driver",
".",
"Value",
")",
"(",
"driver",
".",
"Result",
",",
"error",
")",
"{",
"list",
":=",
"make",
"(",
"[",
"]",
"namedValue",
",",
"len",
"(... | // Exec executes a query | [
"Exec",
"executes",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L16-L25 |
150,476 | mattn/go-oci8 | connection.go | Ping | func (conn *OCI8Conn) Ping(ctx context.Context) error {
result := C.OCIPing(conn.svc, conn.errHandle, C.OCI_DEFAULT)
if result == C.OCI_SUCCESS || result == C.OCI_SUCCESS_WITH_INFO {
return nil
}
errorCode, err := conn.ociGetError()
if errorCode == 1010 {
// Older versions of Oracle do not support ping,
// b... | go | func (conn *OCI8Conn) Ping(ctx context.Context) error {
result := C.OCIPing(conn.svc, conn.errHandle, C.OCI_DEFAULT)
if result == C.OCI_SUCCESS || result == C.OCI_SUCCESS_WITH_INFO {
return nil
}
errorCode, err := conn.ociGetError()
if errorCode == 1010 {
// Older versions of Oracle do not support ping,
// b... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Ping",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"result",
":=",
"C",
".",
"OCIPing",
"(",
"conn",
".",
"svc",
",",
"conn",
".",
"errHandle",
",",
"C",
".",
"OCI_DEFAULT",
")",
"\n",
"if",... | // Ping database connection | [
"Ping",
"database",
"connection"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L54-L69 |
150,477 | mattn/go-oci8 | connection.go | Begin | func (conn *OCI8Conn) Begin() (driver.Tx, error) {
return conn.BeginTx(context.Background(), driver.TxOptions{})
} | go | func (conn *OCI8Conn) Begin() (driver.Tx, error) {
return conn.BeginTx(context.Background(), driver.TxOptions{})
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Begin",
"(",
")",
"(",
"driver",
".",
"Tx",
",",
"error",
")",
"{",
"return",
"conn",
".",
"BeginTx",
"(",
"context",
".",
"Background",
"(",
")",
",",
"driver",
".",
"TxOptions",
"{",
"}",
")",
"\n",
"... | // Begin starts a transaction | [
"Begin",
"starts",
"a",
"transaction"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L72-L74 |
150,478 | mattn/go-oci8 | connection.go | BeginTx | func (conn *OCI8Conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (driver.Tx, error) {
if conn.transactionMode != C.OCI_TRANS_READWRITE {
// transaction handle
trans, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_TRANS, 0)
if err != nil {
return nil, fmt.Errorf("allocate transaction handle error: %v"... | go | func (conn *OCI8Conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (driver.Tx, error) {
if conn.transactionMode != C.OCI_TRANS_READWRITE {
// transaction handle
trans, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_TRANS, 0)
if err != nil {
return nil, fmt.Errorf("allocate transaction handle error: %v"... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"BeginTx",
"(",
"ctx",
"context",
".",
"Context",
",",
"txOptions",
"driver",
".",
"TxOptions",
")",
"(",
"driver",
".",
"Tx",
",",
"error",
")",
"{",
"if",
"conn",
".",
"transactionMode",
"!=",
"C",
".",
"O... | // BeginTx starts a transaction | [
"BeginTx",
"starts",
"a",
"transaction"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L77-L110 |
150,479 | mattn/go-oci8 | connection.go | Prepare | func (conn *OCI8Conn) Prepare(query string) (driver.Stmt, error) {
return conn.PrepareContext(context.Background(), query)
} | go | func (conn *OCI8Conn) Prepare(query string) (driver.Stmt, error) {
return conn.PrepareContext(context.Background(), query)
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"Prepare",
"(",
"query",
"string",
")",
"(",
"driver",
".",
"Stmt",
",",
"error",
")",
"{",
"return",
"conn",
".",
"PrepareContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"query",
")",
"\n",
"}"
... | // Prepare prepares a query | [
"Prepare",
"prepares",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L160-L162 |
150,480 | mattn/go-oci8 | connection.go | PrepareContext | func (conn *OCI8Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
if conn.enableQMPlaceholders {
query = placeholders(query)
}
queryP := cString(query)
defer C.free(unsafe.Pointer(queryP))
// statement handle
stmt, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_STMT, 0)
if err != nil ... | go | func (conn *OCI8Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
if conn.enableQMPlaceholders {
query = placeholders(query)
}
queryP := cString(query)
defer C.free(unsafe.Pointer(queryP))
// statement handle
stmt, _, err := conn.ociHandleAlloc(C.OCI_HTYPE_STMT, 0)
if err != nil ... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"PrepareContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"query",
"string",
")",
"(",
"driver",
".",
"Stmt",
",",
"error",
")",
"{",
"if",
"conn",
".",
"enableQMPlaceholders",
"{",
"query",
"=",
"placeholde... | // PrepareContext prepares a query | [
"PrepareContext",
"prepares",
"a",
"query"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L165-L192 |
150,481 | mattn/go-oci8 | connection.go | ociGetError | func (conn *OCI8Conn) ociGetError() (int, error) {
var errorCode C.sb4
errorText := make([]byte, 1024)
result := C.OCIErrorGet(
unsafe.Pointer(conn.errHandle), // error handle
1, // status record number, starts from 1
nil, // sqlstate, not supported in r... | go | func (conn *OCI8Conn) ociGetError() (int, error) {
var errorCode C.sb4
errorText := make([]byte, 1024)
result := C.OCIErrorGet(
unsafe.Pointer(conn.errHandle), // error handle
1, // status record number, starts from 1
nil, // sqlstate, not supported in r... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociGetError",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"errorCode",
"C",
".",
"sb4",
"\n",
"errorText",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1024",
")",
"\n\n",
"result",
":=",
"C",
".... | // ociGetError calls OCIErrorGet then returs error code and text | [
"ociGetError",
"calls",
"OCIErrorGet",
"then",
"returs",
"error",
"code",
"and",
"text"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L236-L256 |
150,482 | mattn/go-oci8 | connection.go | ociAttrGet | func (conn *OCI8Conn) ociAttrGet(paramHandle *C.OCIParam, value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(paramHandle), // Pointer to a handle type
C.OCI_DTYPE_PARAM, // The handle type: OCI_DTYPE_PARAM, for a parameter descriptor
valu... | go | func (conn *OCI8Conn) ociAttrGet(paramHandle *C.OCIParam, value unsafe.Pointer, attributeType C.ub4) (C.ub4, error) {
var size C.ub4
result := C.OCIAttrGet(
unsafe.Pointer(paramHandle), // Pointer to a handle type
C.OCI_DTYPE_PARAM, // The handle type: OCI_DTYPE_PARAM, for a parameter descriptor
valu... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociAttrGet",
"(",
"paramHandle",
"*",
"C",
".",
"OCIParam",
",",
"value",
"unsafe",
".",
"Pointer",
",",
"attributeType",
"C",
".",
"ub4",
")",
"(",
"C",
".",
"ub4",
",",
"error",
")",
"{",
"var",
"size",
... | // ociAttrGet calls OCIAttrGet with OCIParam then returns attribute size and error.
// The attribute value is stored into passed value. | [
"ociAttrGet",
"calls",
"OCIAttrGet",
"with",
"OCIParam",
"then",
"returns",
"attribute",
"size",
"and",
"error",
".",
"The",
"attribute",
"value",
"is",
"stored",
"into",
"passed",
"value",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L260-L273 |
150,483 | mattn/go-oci8 | connection.go | ociAttrSet | func (conn *OCI8Conn) ociAttrSet(
handle unsafe.Pointer,
handleType C.ub4,
value unsafe.Pointer,
valueSize C.ub4,
attributeType C.ub4,
) error {
result := C.OCIAttrSet(
handle, // Pointer to a handle whose attribute gets modified
handleType, // The handle type
value, // Pointer to an at... | go | func (conn *OCI8Conn) ociAttrSet(
handle unsafe.Pointer,
handleType C.ub4,
value unsafe.Pointer,
valueSize C.ub4,
attributeType C.ub4,
) error {
result := C.OCIAttrSet(
handle, // Pointer to a handle whose attribute gets modified
handleType, // The handle type
value, // Pointer to an at... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociAttrSet",
"(",
"handle",
"unsafe",
".",
"Pointer",
",",
"handleType",
"C",
".",
"ub4",
",",
"value",
"unsafe",
".",
"Pointer",
",",
"valueSize",
"C",
".",
"ub4",
",",
"attributeType",
"C",
".",
"ub4",
",",... | // ociAttrSet calls OCIAttrSet.
// Only uses errHandle from conn, so can be called in conn setup after errHandle has been set. | [
"ociAttrSet",
"calls",
"OCIAttrSet",
".",
"Only",
"uses",
"errHandle",
"from",
"conn",
"so",
"can",
"be",
"called",
"in",
"conn",
"setup",
"after",
"errHandle",
"has",
"been",
"set",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L277-L294 |
150,484 | mattn/go-oci8 | connection.go | ociHandleAlloc | func (conn *OCI8Conn) ociHandleAlloc(handleType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var handleTemp unsafe.Pointer
handle := &handleTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIHandleAlloc(
unsafe.Pointer(conn.... | go | func (conn *OCI8Conn) ociHandleAlloc(handleType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var handleTemp unsafe.Pointer
handle := &handleTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIHandleAlloc(
unsafe.Pointer(conn.... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociHandleAlloc",
"(",
"handleType",
"C",
".",
"ub4",
",",
"size",
"C",
".",
"size_t",
")",
"(",
"*",
"unsafe",
".",
"Pointer",
",",
"*",
"unsafe",
".",
"Pointer",
",",
"error",
")",
"{",
"var",
"handleTemp"... | // ociHandleAlloc calls OCIHandleAlloc then returns
// handle pointer to pointer, buffer pointer to pointer, and error | [
"ociHandleAlloc",
"calls",
"OCIHandleAlloc",
"then",
"returns",
"handle",
"pointer",
"to",
"pointer",
"buffer",
"pointer",
"to",
"pointer",
"and",
"error"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L298-L325 |
150,485 | mattn/go-oci8 | connection.go | ociDescriptorAlloc | func (conn *OCI8Conn) ociDescriptorAlloc(descriptorType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var descriptorTemp unsafe.Pointer
descriptor := &descriptorTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIDescriptorAlloc... | go | func (conn *OCI8Conn) ociDescriptorAlloc(descriptorType C.ub4, size C.size_t) (*unsafe.Pointer, *unsafe.Pointer, error) {
var descriptorTemp unsafe.Pointer
descriptor := &descriptorTemp
var bufferTemp unsafe.Pointer
var buffer *unsafe.Pointer
if size > 0 {
buffer = &bufferTemp
}
result := C.OCIDescriptorAlloc... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociDescriptorAlloc",
"(",
"descriptorType",
"C",
".",
"ub4",
",",
"size",
"C",
".",
"size_t",
")",
"(",
"*",
"unsafe",
".",
"Pointer",
",",
"*",
"unsafe",
".",
"Pointer",
",",
"error",
")",
"{",
"var",
"des... | // ociDescriptorAlloc calls OCIDescriptorAlloc then returns
// descriptor pointer to pointer, buffer pointer to pointer, and error | [
"ociDescriptorAlloc",
"calls",
"OCIDescriptorAlloc",
"then",
"returns",
"descriptor",
"pointer",
"to",
"pointer",
"buffer",
"pointer",
"to",
"pointer",
"and",
"error"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L329-L356 |
150,486 | mattn/go-oci8 | connection.go | ociLobRead | func (conn *OCI8Conn) ociLobRead(lobLocator *C.OCILobLocator, form C.ub1) ([]byte, error) {
readBuffer := make([]byte, lobBufferSize)
buffer := make([]byte, 0)
result := (C.sword)(C.OCI_NEED_DATA)
piece := (C.ub1)(C.OCI_FIRST_PIECE)
for result == C.OCI_NEED_DATA {
readBytes := (C.oraub8)(0)
// If both byte_a... | go | func (conn *OCI8Conn) ociLobRead(lobLocator *C.OCILobLocator, form C.ub1) ([]byte, error) {
readBuffer := make([]byte, lobBufferSize)
buffer := make([]byte, 0)
result := (C.sword)(C.OCI_NEED_DATA)
piece := (C.ub1)(C.OCI_FIRST_PIECE)
for result == C.OCI_NEED_DATA {
readBytes := (C.oraub8)(0)
// If both byte_a... | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"ociLobRead",
"(",
"lobLocator",
"*",
"C",
".",
"OCILobLocator",
",",
"form",
"C",
".",
"ub1",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"readBuffer",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
... | // ociLobRead calls OCILobRead then returns lob bytes and error. | [
"ociLobRead",
"calls",
"OCILobRead",
"then",
"returns",
"lob",
"bytes",
"and",
"error",
"."
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connection.go#L359-L395 |
150,487 | mattn/go-oci8 | connector.go | NewConnector | func NewConnector(hosts ...string) driver.Connector {
return &OCI8Connector{
Logger: log.New(ioutil.Discard, "", 0),
}
} | go | func NewConnector(hosts ...string) driver.Connector {
return &OCI8Connector{
Logger: log.New(ioutil.Discard, "", 0),
}
} | [
"func",
"NewConnector",
"(",
"hosts",
"...",
"string",
")",
"driver",
".",
"Connector",
"{",
"return",
"&",
"OCI8Connector",
"{",
"Logger",
":",
"log",
".",
"New",
"(",
"ioutil",
".",
"Discard",
",",
"\"",
"\"",
",",
"0",
")",
",",
"}",
"\n",
"}"
] | // NewConnector returns a new database connector | [
"NewConnector",
"returns",
"a",
"new",
"database",
"connector"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connector.go#L13-L17 |
150,488 | mattn/go-oci8 | connector.go | Connect | func (oci8Connector *OCI8Connector) Connect(ctx context.Context) (driver.Conn, error) {
oci8Conn := &OCI8Conn{
logger: oci8Connector.Logger,
}
if oci8Conn.logger == nil {
oci8Conn.logger = log.New(ioutil.Discard, "", 0)
}
return oci8Conn, nil
} | go | func (oci8Connector *OCI8Connector) Connect(ctx context.Context) (driver.Conn, error) {
oci8Conn := &OCI8Conn{
logger: oci8Connector.Logger,
}
if oci8Conn.logger == nil {
oci8Conn.logger = log.New(ioutil.Discard, "", 0)
}
return oci8Conn, nil
} | [
"func",
"(",
"oci8Connector",
"*",
"OCI8Connector",
")",
"Connect",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"driver",
".",
"Conn",
",",
"error",
")",
"{",
"oci8Conn",
":=",
"&",
"OCI8Conn",
"{",
"logger",
":",
"oci8Connector",
".",
"Logger",
","... | // Connect returns a new database connection | [
"Connect",
"returns",
"a",
"new",
"database",
"connection"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/connector.go#L25-L34 |
150,489 | mattn/go-oci8 | oci8.go | Commit | func (tx *OCI8Tx) Commit() error {
tx.conn.inTransaction = false
if rv := C.OCITransCommit(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | go | func (tx *OCI8Tx) Commit() error {
tx.conn.inTransaction = false
if rv := C.OCITransCommit(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | [
"func",
"(",
"tx",
"*",
"OCI8Tx",
")",
"Commit",
"(",
")",
"error",
"{",
"tx",
".",
"conn",
".",
"inTransaction",
"=",
"false",
"\n",
"if",
"rv",
":=",
"C",
".",
"OCITransCommit",
"(",
"tx",
".",
"conn",
".",
"svc",
",",
"tx",
".",
"conn",
".",
... | // Commit transaction commit | [
"Commit",
"transaction",
"commit"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8.go#L130-L140 |
150,490 | mattn/go-oci8 | oci8.go | Rollback | func (tx *OCI8Tx) Rollback() error {
tx.conn.inTransaction = false
if rv := C.OCITransRollback(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | go | func (tx *OCI8Tx) Rollback() error {
tx.conn.inTransaction = false
if rv := C.OCITransRollback(
tx.conn.svc,
tx.conn.errHandle,
0,
); rv != C.OCI_SUCCESS {
return tx.conn.getError(rv)
}
return nil
} | [
"func",
"(",
"tx",
"*",
"OCI8Tx",
")",
"Rollback",
"(",
")",
"error",
"{",
"tx",
".",
"conn",
".",
"inTransaction",
"=",
"false",
"\n",
"if",
"rv",
":=",
"C",
".",
"OCITransRollback",
"(",
"tx",
".",
"conn",
".",
"svc",
",",
"tx",
".",
"conn",
".... | // Rollback transaction rollback | [
"Rollback",
"transaction",
"rollback"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8.go#L143-L153 |
150,491 | mattn/go-oci8 | oci8.go | LastInsertId | func (result *OCI8Result) LastInsertId() (int64, error) {
return int64(uintptr(unsafe.Pointer(&result.rowid))), result.rowidErr
} | go | func (result *OCI8Result) LastInsertId() (int64, error) {
return int64(uintptr(unsafe.Pointer(&result.rowid))), result.rowidErr
} | [
"func",
"(",
"result",
"*",
"OCI8Result",
")",
"LastInsertId",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"int64",
"(",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"result",
".",
"rowid",
")",
")",
")",
",",
"result",
".",
"r... | // LastInsertId returns last inserted ID | [
"LastInsertId",
"returns",
"last",
"inserted",
"ID"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8.go#L364-L366 |
150,492 | mattn/go-oci8 | oci8_go18.go | CheckNamedValue | func (conn *OCI8Conn) CheckNamedValue(nv *driver.NamedValue) error {
switch nv.Value.(type) {
default:
return driver.ErrSkip
case sql.Out:
return nil
}
} | go | func (conn *OCI8Conn) CheckNamedValue(nv *driver.NamedValue) error {
switch nv.Value.(type) {
default:
return driver.ErrSkip
case sql.Out:
return nil
}
} | [
"func",
"(",
"conn",
"*",
"OCI8Conn",
")",
"CheckNamedValue",
"(",
"nv",
"*",
"driver",
".",
"NamedValue",
")",
"error",
"{",
"switch",
"nv",
".",
"Value",
".",
"(",
"type",
")",
"{",
"default",
":",
"return",
"driver",
".",
"ErrSkip",
"\n",
"case",
... | // CheckNamedValue checks the named value | [
"CheckNamedValue",
"checks",
"the",
"named",
"value"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/oci8_go18.go#L52-L59 |
150,493 | mattn/go-oci8 | cHelpers.go | cByte | func cByte(b []byte) *C.OraText {
p := C.malloc(C.size_t(len(b)))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | go | func cByte(b []byte) *C.OraText {
p := C.malloc(C.size_t(len(b)))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | [
"func",
"cByte",
"(",
"b",
"[",
"]",
"byte",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"len",
"(",
"b",
")",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte",
... | // cByte comverts byte slice to OraText.
// must be freed | [
"cByte",
"comverts",
"byte",
"slice",
"to",
"OraText",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L22-L27 |
150,494 | mattn/go-oci8 | cHelpers.go | cByteN | func cByteN(b []byte, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | go | func cByteN(b []byte, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], b)
return (*C.OraText)(p)
} | [
"func",
"cByteN",
"(",
"b",
"[",
"]",
"byte",
",",
"size",
"int",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"size",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"b... | // cByteN comverts byte slice to C OraText with size.
// must be freed | [
"cByteN",
"comverts",
"byte",
"slice",
"to",
"C",
"OraText",
"with",
"size",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L31-L36 |
150,495 | mattn/go-oci8 | cHelpers.go | cString | func cString(s string) *C.OraText {
p := C.malloc(C.size_t(len(s) + 1))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
pp[len(s)] = 0
return (*C.OraText)(p)
} | go | func cString(s string) *C.OraText {
p := C.malloc(C.size_t(len(s) + 1))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
pp[len(s)] = 0
return (*C.OraText)(p)
} | [
"func",
"cString",
"(",
"s",
"string",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"len",
"(",
"s",
")",
"+",
"1",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte... | // cString coverts string to C OraText.
// must be freed | [
"cString",
"coverts",
"string",
"to",
"C",
"OraText",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L40-L46 |
150,496 | mattn/go-oci8 | cHelpers.go | cStringN | func cStringN(s string, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
if len(s) < size {
pp[len(s)] = 0
} else {
pp[size-1] = 0
}
return (*C.OraText)(p)
} | go | func cStringN(s string, size int) *C.OraText {
p := C.malloc(C.size_t(size))
pp := (*[1 << 30]byte)(p)
copy(pp[:], s)
if len(s) < size {
pp[len(s)] = 0
} else {
pp[size-1] = 0
}
return (*C.OraText)(p)
} | [
"func",
"cStringN",
"(",
"s",
"string",
",",
"size",
"int",
")",
"*",
"C",
".",
"OraText",
"{",
"p",
":=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"size",
")",
")",
"\n",
"pp",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte",
")... | // cStringN coverts string to C OraText with size.
// must be freed | [
"cStringN",
"coverts",
"string",
"to",
"C",
"OraText",
"with",
"size",
".",
"must",
"be",
"freed"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L50-L60 |
150,497 | mattn/go-oci8 | cHelpers.go | cGoStringN | func cGoStringN(s *C.OraText, size int) string {
if size == 0 {
return ""
}
p := (*[1 << 30]byte)(unsafe.Pointer(s))
buf := make([]byte, size)
copy(buf, p[:])
return *(*string)(unsafe.Pointer(&buf))
} | go | func cGoStringN(s *C.OraText, size int) string {
if size == 0 {
return ""
}
p := (*[1 << 30]byte)(unsafe.Pointer(s))
buf := make([]byte, size)
copy(buf, p[:])
return *(*string)(unsafe.Pointer(&buf))
} | [
"func",
"cGoStringN",
"(",
"s",
"*",
"C",
".",
"OraText",
",",
"size",
"int",
")",
"string",
"{",
"if",
"size",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"p",
":=",
"(",
"*",
"[",
"1",
"<<",
"30",
"]",
"byte",
")",
"(",
"unsafe",... | // CGoStringN coverts C OraText to Go string | [
"CGoStringN",
"coverts",
"C",
"OraText",
"to",
"Go",
"string"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L63-L71 |
150,498 | mattn/go-oci8 | cHelpers.go | freeDefines | func freeDefines(defines []oci8Define) {
for _, define := range defines {
if define.pbuf != nil {
freeBuffer(define.pbuf, define.dataType)
define.pbuf = nil
}
if define.length != nil {
C.free(unsafe.Pointer(define.length))
define.length = nil
}
if define.indicator != nil {
C.free(unsafe.Pointe... | go | func freeDefines(defines []oci8Define) {
for _, define := range defines {
if define.pbuf != nil {
freeBuffer(define.pbuf, define.dataType)
define.pbuf = nil
}
if define.length != nil {
C.free(unsafe.Pointer(define.length))
define.length = nil
}
if define.indicator != nil {
C.free(unsafe.Pointe... | [
"func",
"freeDefines",
"(",
"defines",
"[",
"]",
"oci8Define",
")",
"{",
"for",
"_",
",",
"define",
":=",
"range",
"defines",
"{",
"if",
"define",
".",
"pbuf",
"!=",
"nil",
"{",
"freeBuffer",
"(",
"define",
".",
"pbuf",
",",
"define",
".",
"dataType",
... | // freeDefines frees defines | [
"freeDefines",
"frees",
"defines"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L74-L90 |
150,499 | mattn/go-oci8 | cHelpers.go | freeBinds | func freeBinds(binds []oci8Bind) {
for _, bind := range binds {
if bind.pbuf != nil {
freeBuffer(bind.pbuf, bind.dataType)
bind.pbuf = nil
}
if bind.length != nil {
C.free(unsafe.Pointer(bind.length))
bind.length = nil
}
if bind.indicator != nil {
C.free(unsafe.Pointer(bind.indicator))
bind... | go | func freeBinds(binds []oci8Bind) {
for _, bind := range binds {
if bind.pbuf != nil {
freeBuffer(bind.pbuf, bind.dataType)
bind.pbuf = nil
}
if bind.length != nil {
C.free(unsafe.Pointer(bind.length))
bind.length = nil
}
if bind.indicator != nil {
C.free(unsafe.Pointer(bind.indicator))
bind... | [
"func",
"freeBinds",
"(",
"binds",
"[",
"]",
"oci8Bind",
")",
"{",
"for",
"_",
",",
"bind",
":=",
"range",
"binds",
"{",
"if",
"bind",
".",
"pbuf",
"!=",
"nil",
"{",
"freeBuffer",
"(",
"bind",
".",
"pbuf",
",",
"bind",
".",
"dataType",
")",
"\n",
... | // freeBinds frees binds | [
"freeBinds",
"frees",
"binds"
] | b4ff95311f59786a15c0688c8beff047414c098f | https://github.com/mattn/go-oci8/blob/b4ff95311f59786a15c0688c8beff047414c098f/cHelpers.go#L93-L109 |
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.