From: Shengjing Zhu <zhsj@debian.org>
Date: Sat, 14 Nov 2020 23:22:58 +0800
Subject: Backward compatibility for field name change in mountinfo.Info

This patch can be dropped when runc and golang-github-containers-storage
are updated.
---
 mountinfo/mountinfo.go            | 4 ++++
 mountinfo/mountinfo_linux.go      | 5 +++++
 mountinfo/mountinfo_linux_test.go | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/mountinfo/mountinfo.go b/mountinfo/mountinfo.go
index 403a893..699902b 100644
--- a/mountinfo/mountinfo.go
+++ b/mountinfo/mountinfo.go
@@ -63,4 +63,8 @@ type Info struct {
 
 	// VFSOptions is a comma-separated list of superblock options.
 	VFSOptions string
+
+	// Following fileds are for backward compatibility. They are populated only in
+	// GetMountsFromReader function, which is called by GetMounts.
+	Fstype string
 }
diff --git a/mountinfo/mountinfo_linux.go b/mountinfo/mountinfo_linux.go
index f09a70f..938fb3c 100644
--- a/mountinfo/mountinfo_linux.go
+++ b/mountinfo/mountinfo_linux.go
@@ -19,6 +19,11 @@ import (
 func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
 	s := bufio.NewScanner(r)
 	out := []*Info{}
+	defer func() {
+		for i := range out {
+			out[i].Fstype = out[i].FSType
+		}
+	}()
 	for s.Scan() {
 		var err error
 
diff --git a/mountinfo/mountinfo_linux_test.go b/mountinfo/mountinfo_linux_test.go
index afca234..3785d5c 100644
--- a/mountinfo/mountinfo_linux_test.go
+++ b/mountinfo/mountinfo_linux_test.go
@@ -470,6 +470,7 @@ func TestParseFedoraMountinfoFields(t *testing.T) {
 		FSType:     "proc",
 		Source:     "proc",
 		VFSOptions: "rw",
+		Fstype:     "proc",
 	}
 
 	if *infos[0] != mi {
@@ -523,6 +524,7 @@ func TestParseMountinfoWithSpaces(t *testing.T) {
 			FSType:     "ext4",
 			Source:     "/dev/vda1",
 			VFSOptions: "rw,data=ordered",
+			Fstype:     "ext4",
 		},
 		{
 			ID:         31,
@@ -536,6 +538,7 @@ func TestParseMountinfoWithSpaces(t *testing.T) {
 			FSType:     "cifs",
 			Source:     `//foo/BLA BLA BLA/`,
 			VFSOptions: `rw,sec=ntlm,cache=loose,unc=\\foo\BLA`,
+			Fstype:     "cifs",
 		},
 		{
 			ID:     649,
@@ -551,6 +554,7 @@ tab	space backslash\quote1'quote2"`,
 			FSType:     "ext4",
 			Source:     `/dev/nvme0n1p5`,
 			VFSOptions: `rw,seclabel`,
+			Fstype:     "ext4",
 		},
 	}
 
