fs: fix XFS and other FS related issue due to missing d_type.
This commit is contained in:
parent
188bb92d8a
commit
3de7f26e41
2
Makefile
2
Makefile
|
@ -131,9 +131,11 @@ install: gomake-all
|
|||
dockerimage: checkdocker getdeps verifiers $(UI_ASSETS)
|
||||
@echo "Building docker image:" minio:$(TAG)
|
||||
@GO15VENDOREXPERIMENT=1 GOOS=linux GOARCH=amd64 go build --ldflags $(DOCKER_LDFLAGS) -o docker/minio.dockerimage
|
||||
@touch docker/dockerinit
|
||||
@cd docker; mkdir -p export; sudo docker build --rm --tag=minio/minio:$(TAG) .
|
||||
@rmdir docker/export
|
||||
@rm docker/minio.dockerimage
|
||||
@rm docker/dockerinit
|
||||
|
||||
release: verifiers
|
||||
@MINIO_RELEASE=RELEASE ./buildscripts/build.sh
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
FROM alpine:3.3
|
||||
RUN apk add --no-cache ca-certificates bash
|
||||
ADD minio.dockerimage /minio
|
||||
ADD dockerinit /.dockerinit
|
||||
ADD export /export
|
||||
EXPOSE 9000
|
||||
COPY start.sh /start.sh
|
||||
|
|
|
@ -48,7 +48,7 @@ func clen(n []byte) int {
|
|||
|
||||
// parseDirents - inspired from
|
||||
// https://golang.org/src/syscall/syscall_<os>.go
|
||||
func parseDirents(buf []byte) []fsDirent {
|
||||
func parseDirents(dirPath string, buf []byte) []fsDirent {
|
||||
bufidx := 0
|
||||
dirents := []fsDirent{}
|
||||
for bufidx < len(buf) {
|
||||
|
@ -87,7 +87,16 @@ func parseDirents(buf []byte) []fsDirent {
|
|||
case syscall.DT_SOCK:
|
||||
mode = os.ModeSocket
|
||||
case syscall.DT_UNKNOWN:
|
||||
mode = 0xffffffff
|
||||
// On Linux XFS and few other file systems do not implement d_type in dirents.
|
||||
// Fall back to Stat() in these scenarios.
|
||||
if fi, err := os.Stat(filepath.Join(dirPath, name)); err == nil {
|
||||
mode = fi.Mode()
|
||||
} else {
|
||||
// Stat failed, caller listing files would fail. But we will not crash
|
||||
// the server.
|
||||
mode = 0xffffffff
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dirents = append(dirents, fsDirent{
|
||||
|
@ -115,7 +124,7 @@ func readDirAll(readDirPath, entryPrefixMatch string) ([]fsDirent, error) {
|
|||
if nbuf <= 0 {
|
||||
break
|
||||
}
|
||||
for _, dirent := range parseDirents(buf[:nbuf]) {
|
||||
for _, dirent := range parseDirents(readDirPath, buf[:nbuf]) {
|
||||
if dirent.IsDir() {
|
||||
dirent.name += string(os.PathSeparator)
|
||||
dirent.size = 0
|
||||
|
@ -151,7 +160,7 @@ func scandir(dirPath string, filter func(fsDirent) bool, namesOnly bool) ([]fsDi
|
|||
if nbuf <= 0 {
|
||||
break
|
||||
}
|
||||
for _, dirent := range parseDirents(buf[:nbuf]) {
|
||||
for _, dirent := range parseDirents(dirPath, buf[:nbuf]) {
|
||||
if !namesOnly {
|
||||
dirent.name = filepath.Join(dirPath, dirent.name)
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ func initServerConfig(c *cli.Context) {
|
|||
|
||||
// Check server arguments.
|
||||
func checkServerSyntax(c *cli.Context) {
|
||||
if c.Args().First() == "help" {
|
||||
if !c.Args().Present() || c.Args().First() == "help" {
|
||||
cli.ShowCommandHelpAndExit(c, "server", 1)
|
||||
}
|
||||
if len(c.Args()) > 2 {
|
||||
|
|
Loading…
Reference in a new issue