diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-22 06:49:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 06:49:53 -0700 |
commit | c1f2f75f03853a7cd04dd5e5495700e5fdffcafd (patch) | |
tree | dc7b0945cb241b1f869a6048dcc54d84a13b2509 /vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go | |
parent | df1d5618dd4b46f4c24d0c196d6fbaab4e34640f (diff) | |
parent | 3b609a706d0e940a244ca7643e2afb7f3c996711 (diff) | |
download | podman-c1f2f75f03853a7cd04dd5e5495700e5fdffcafd.tar.gz podman-c1f2f75f03853a7cd04dd5e5495700e5fdffcafd.tar.bz2 podman-c1f2f75f03853a7cd04dd5e5495700e5fdffcafd.zip |
Merge pull request #9779 from containers/dependabot/go_modules/github.com/coreos/go-systemd/v22-22.3.0
Bump github.com/coreos/go-systemd/v22 from 22.1.0 to 22.3.0
Diffstat (limited to 'vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go')
-rw-r--r-- | vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go b/vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go index 7f840def8..344016ebe 100644 --- a/vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go +++ b/vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go @@ -300,6 +300,24 @@ package sdjournal // return sd_journal_get_catalog(j, ret); // } // +// int +// my_sd_id128_get_boot(void *f, sd_id128_t *boot_id) +// { +// int(*sd_id128_get_boot)(sd_id128_t *); +// +// sd_id128_get_boot = f; +// return sd_id128_get_boot(boot_id); +// } +// +// char * +// my_sd_id128_to_string(void *f, sd_id128_t boot_id, char s[SD_ID128_STRING_MAX]) +// { +// char *(*sd_id128_to_string)(sd_id128_t, char *); +// +// sd_id128_to_string = f; +// return sd_id128_to_string(boot_id, s); +// } +// import "C" import ( "bytes" @@ -928,7 +946,7 @@ func (j *Journal) SeekHead() error { } // SeekTail may be used to seek to the end of the journal, i.e. the most recent -// available entry. This call must be followed by a call to Next before any +// available entry. This call must be followed by a call to Previous before any // call to Get* will return data about the last element. func (j *Journal) SeekTail() error { sd_journal_seek_tail, err := getFunction("sd_journal_seek_tail") @@ -1118,3 +1136,34 @@ func (j *Journal) GetCatalog() (string, error) { return catalog, nil } + +// GetBootID get systemd boot id +func (j *Journal) GetBootID() (string, error) { + sd_id128_get_boot, err := getFunction("sd_id128_get_boot") + if err != nil { + return "", err + } + + var boot_id C.sd_id128_t + r := C.my_sd_id128_get_boot(sd_id128_get_boot, &boot_id) + if r < 0 { + return "", fmt.Errorf("failed to get boot id: %s", syscall.Errno(-r).Error()) + } + + sd_id128_to_string, err := getFunction("sd_id128_to_string") + if err != nil { + return "", err + } + + id128StringMax := C.ulong(C.SD_ID128_STRING_MAX) + c := (*C.char)(C.malloc(id128StringMax)) + defer C.free(unsafe.Pointer(c)) + C.my_sd_id128_to_string(sd_id128_to_string, boot_id, c) + + bootID := C.GoString(c) + if len(bootID) <= 0 { + return "", fmt.Errorf("get boot id %s is not valid", bootID) + } + + return bootID, nil +} |