386: Support 'mc' for linux 32bit operating systems

This commit is contained in:
Harshavardhana
2015-11-13 23:22:00 -08:00
parent 5b5327d61a
commit 5ba1266f5b
2 changed files with 26 additions and 3 deletions
+2 -3
View File
@@ -18,7 +18,6 @@ package main
import (
"os"
"os/user"
"path/filepath"
"runtime"
"strings"
@@ -93,9 +92,9 @@ func getMcConfigDir() (string, *probe.Error) {
if mcCustomConfigDir != "" {
return mcCustomConfigDir, nil
}
u, err := user.Current()
u, err := userCurrent()
if err != nil {
return "", probe.NewError(err)
return "", err.Trace()
}
// For windows the path is slightly different
switch runtime.GOOS {
+24
View File
@@ -18,8 +18,14 @@ package main
import (
"math/rand"
"os"
"os/user"
"path/filepath"
"runtime"
"strconv"
"time"
"github.com/minio/minio-xl/pkg/probe"
)
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
@@ -39,3 +45,21 @@ func isBucketVirtualStyle(host string) bool {
googleVirtual, _ := filepath.Match("*.storage.googleapis.com", host)
return s3Virtual || googleVirtual
}
// user.Current is not implemented on 32bit, falling back and using a workaround instead.
func userCurrent() (*user.User, *probe.Error) {
if runtime.GOARCH == "386" && runtime.GOOS == "linux" {
return &user.User{
Uid: strconv.Itoa(os.Getuid()),
Gid: strconv.Itoa(os.Getgid()),
Username: os.Getenv("USER"),
Name: os.Getenv("USER"),
HomeDir: os.Getenv("HOME"),
}, nil
}
user, err := user.Current()
if err != nil {
return nil, probe.NewError(err)
}
return user, nil
}