~emersion/drmdb

6a998e846f32ecc1c4ba4cef5b32e64b2d08a15b — Simon Ser 7 months ago e276b22
Detect and warn kernels compiled from Git and RCs
2 files changed, 29 insertions(+), 0 deletions(-)

M drmtree/drmtree.go
M public/snapshot.html
M drmtree/drmtree.go => drmtree/drmtree.go +26 -0
@@ 95,6 95,32 @@ func (k *Kernel) String() string {
	return s
}

func (k *Kernel) IsUnstableRelease() bool {
	if k.SysName != "Linux" {
		return false // TODO
	}

	for _, field := range strings.Split(k.Release, "-") {
		if field == "dirty" {
			return true
		}
		if len(field) == 13 && field[0] == 'g' && isHex(field[1:]) {
			return true // Git hash
		}
	}

	return false
}

func isHex(s string) bool {
	for _, ch := range s {
		if (ch < '0' || ch > '9') && (ch < 'a' || ch > 'f') {
			return false
		}
	}
	return true
}

type Driver struct {
	Name       string             `json:"name"`
	Desc       string             `json:"desc"`

M public/snapshot.html => public/snapshot.html +3 -0
@@ 138,6 138,9 @@
    <p class="warning">⚠ This snapshot was captured with an external module loaded.</p>
  {{end}}
{{end}}
{{if .Node.Driver.Kernel.IsUnstableRelease}}
  <p class="warning">⚠ This snapshot was not captured on a stable kernel release.</p>
{{end}}

{{with .Node}}
<ul class="pre">