Browse Source

filer copy added uid/gid

pull/664/head
Chris Lu 7 years ago
parent
commit
9dd228747c
  1. 5
      weed/command/filer_copy.go
  2. 4
      weed/filer2/filer.go
  3. 3
      weed/filer2/filer_structure.go
  4. 49
      weed/filesys/dir.go
  5. 4
      weed/filesys/file.go
  6. 4
      weed/operation/filer/register.go
  7. 6
      weed/pb/filer.proto
  8. 158
      weed/pb/filer_pb/filer.pb.go
  9. 10
      weed/server/filer_grpc_server.go
  10. 14
      weed/server/filer_server_handlers_admin.go

5
weed/command/filer_copy.go

@ -68,7 +68,7 @@ func runCopy(cmd *Command, args []string) bool {
return false
}
filerDestination := args[len(args)-1]
fileOrDirs := args[0 : len(args)-1]
fileOrDirs := args[0: len(args)-1]
filerUrl, err := url.Parse(filerDestination)
if err != nil {
@ -136,7 +136,8 @@ func doEachCopy(fileOrDir string, host string, path string) bool {
path = path + fi.Name()
}
if err = filer_operation.RegisterFile(host, path, results[0].Fid, parts[0].FileSize, copy.secret); err != nil {
if err = filer_operation.RegisterFile(host, path, results[0].Fid, parts[0].FileSize,
os.Getuid(), os.Getgid(), copy.secret); err != nil {
fmt.Printf("Failed to register file %s on %s: %v\n", fileOrDir, host, err)
return false
}

4
weed/filer2/filer.go

@ -71,13 +71,13 @@ func (f *Filer) CreateEntry(entry *Entry) (error) {
Attr: Attr{
Mtime: now,
Crtime: now,
Mode: os.ModeDir | 0660,
Mode: os.ModeDir | 0770,
Uid: entry.Uid,
Gid: entry.Gid,
},
}
glog.V(2).Infof("create directory: %s", dirPath)
glog.V(2).Infof("create directory: %s %v", dirPath, dirEntry.Mode)
mkdirErr := f.store.InsertEntry(dirEntry)
if mkdirErr != nil {
return fmt.Errorf("mkdir %s: %v", dirPath, mkdirErr)

3
weed/filer2/filer_structure.go

@ -6,12 +6,13 @@ import (
"time"
"path/filepath"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"strings"
)
type FullPath string
func NewFullPath(dir, name string) FullPath {
if dir == "/" {
if strings.HasSuffix(dir, "/") {
return FullPath(dir + name)
}
return FullPath(dir + "/" + name)

49
weed/filesys/dir.go

@ -12,6 +12,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"time"
"path/filepath"
)
type Dir struct {
@ -25,7 +26,53 @@ var _ = fs.Node(&Dir{})
var _ = fs.HandleReadDirAller(&Dir{})
func (dir *Dir) Attr(context context.Context, attr *fuse.Attr) error {
attr.Mode = os.ModeDir | 0777
if dir.Path == "/" {
attr.Valid = time.Second
attr.Mode = os.ModeDir | 0777
return nil
}
parent, name := filepath.Split(dir.Path)
var attributes *filer_pb.FuseAttributes
err := dir.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
request := &filer_pb.GetEntryAttributesRequest{
Name: name,
ParentDir: parent,
}
glog.V(1).Infof("read dir attr: %v", request)
resp, err := client.GetEntryAttributes(context, request)
if err != nil {
glog.V(0).Infof("read dir attr %v: %v", request, err)
return err
}
attributes = resp.Attributes
return nil
})
if err != nil {
return err
}
// glog.V(1).Infof("dir %s: %v", dir.Path, attributes)
// glog.V(1).Infof("dir %s permission: %v", dir.Path, os.FileMode(attributes.FileMode))
attr.Mode = os.FileMode(attributes.FileMode) | os.ModeDir
if dir.Path == "/" && attributes.FileMode == 0 {
attr.Valid = time.Second
}
attr.Mtime = time.Unix(attributes.Mtime, 0)
attr.Ctime = time.Unix(attributes.Mtime, 0)
attr.Gid = attributes.Gid
attr.Uid = attributes.Uid
return nil
}

4
weed/filesys/file.go

@ -44,13 +44,13 @@ func (file *File) Attr(context context.Context, attr *fuse.Attr) error {
} else {
err := file.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
request := &filer_pb.GetFileAttributesRequest{
request := &filer_pb.GetEntryAttributesRequest{
Name: file.Name,
ParentDir: file.dir.Path,
}
glog.V(1).Infof("read file size: %v", request)
resp, err := client.GetFileAttributes(context, request)
resp, err := client.GetEntryAttributes(context, request)
if err != nil {
glog.V(0).Infof("read file attributes %v: %v", request, err)
return err

4
weed/operation/filer/register.go

@ -17,7 +17,7 @@ type SubmitResult struct {
Error string `json:"error,omitempty"`
}
func RegisterFile(filer string, path string, fileId string, fileSize int64, secret security.Secret) error {
func RegisterFile(filer string, path string, fileId string, fileSize int64, uid, gid int, secret security.Secret) error {
// TODO: jwt need to be used
_ = security.GenJwt(secret, fileId)
@ -25,6 +25,8 @@ func RegisterFile(filer string, path string, fileId string, fileSize int64, secr
values.Add("path", path)
values.Add("fileId", fileId)
values.Add("fileSize", strconv.FormatInt(fileSize, 10))
values.Add("uid", strconv.Itoa(uid))
values.Add("gid", strconv.Itoa(gid))
_, err := util.Post("http://"+filer+"/admin/register", values)
if err != nil {
return fmt.Errorf("Failed to register path %s on filer %s to file id %s : %v", path, filer, fileId, err)

6
weed/pb/filer.proto

@ -12,7 +12,7 @@ service SeaweedFiler {
rpc ListEntries (ListEntriesRequest) returns (ListEntriesResponse) {
}
rpc GetFileAttributes (GetFileAttributesRequest) returns (GetFileAttributesResponse) {
rpc GetEntryAttributes (GetEntryAttributesRequest) returns (GetEntryAttributesResponse) {
}
rpc GetFileContent (GetFileContentRequest) returns (GetFileContentResponse) {
@ -73,13 +73,13 @@ message FuseAttributes {
uint32 gid = 5;
}
message GetFileAttributesRequest {
message GetEntryAttributesRequest {
string name = 1;
string parent_dir = 2;
string file_id = 3;
}
message GetFileAttributesResponse {
message GetEntryAttributesResponse {
FuseAttributes attributes = 1;
}

158
weed/pb/filer_pb/filer.pb.go

@ -16,8 +16,8 @@ It has these top-level messages:
Entry
FileChunk
FuseAttributes
GetFileAttributesRequest
GetFileAttributesResponse
GetEntryAttributesRequest
GetEntryAttributesResponse
GetFileContentRequest
GetFileContentResponse
CreateEntryRequest
@ -251,48 +251,48 @@ func (m *FuseAttributes) GetGid() uint32 {
return 0
}
type GetFileAttributesRequest struct {
type GetEntryAttributesRequest struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
ParentDir string `protobuf:"bytes,2,opt,name=parent_dir,json=parentDir" json:"parent_dir,omitempty"`
FileId string `protobuf:"bytes,3,opt,name=file_id,json=fileId" json:"file_id,omitempty"`
}
func (m *GetFileAttributesRequest) Reset() { *m = GetFileAttributesRequest{} }
func (m *GetFileAttributesRequest) String() string { return proto.CompactTextString(m) }
func (*GetFileAttributesRequest) ProtoMessage() {}
func (*GetFileAttributesRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *GetEntryAttributesRequest) Reset() { *m = GetEntryAttributesRequest{} }
func (m *GetEntryAttributesRequest) String() string { return proto.CompactTextString(m) }
func (*GetEntryAttributesRequest) ProtoMessage() {}
func (*GetEntryAttributesRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *GetFileAttributesRequest) GetName() string {
func (m *GetEntryAttributesRequest) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *GetFileAttributesRequest) GetParentDir() string {
func (m *GetEntryAttributesRequest) GetParentDir() string {
if m != nil {
return m.ParentDir
}
return ""
}
func (m *GetFileAttributesRequest) GetFileId() string {
func (m *GetEntryAttributesRequest) GetFileId() string {
if m != nil {
return m.FileId
}
return ""
}
type GetFileAttributesResponse struct {
type GetEntryAttributesResponse struct {
Attributes *FuseAttributes `protobuf:"bytes,1,opt,name=attributes" json:"attributes,omitempty"`
}
func (m *GetFileAttributesResponse) Reset() { *m = GetFileAttributesResponse{} }
func (m *GetFileAttributesResponse) String() string { return proto.CompactTextString(m) }
func (*GetFileAttributesResponse) ProtoMessage() {}
func (*GetFileAttributesResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
func (m *GetEntryAttributesResponse) Reset() { *m = GetEntryAttributesResponse{} }
func (m *GetEntryAttributesResponse) String() string { return proto.CompactTextString(m) }
func (*GetEntryAttributesResponse) ProtoMessage() {}
func (*GetEntryAttributesResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
func (m *GetFileAttributesResponse) GetAttributes() *FuseAttributes {
func (m *GetEntryAttributesResponse) GetAttributes() *FuseAttributes {
if m != nil {
return m.Attributes
}
@ -515,8 +515,8 @@ func init() {
proto.RegisterType((*Entry)(nil), "filer_pb.Entry")
proto.RegisterType((*FileChunk)(nil), "filer_pb.FileChunk")
proto.RegisterType((*FuseAttributes)(nil), "filer_pb.FuseAttributes")
proto.RegisterType((*GetFileAttributesRequest)(nil), "filer_pb.GetFileAttributesRequest")
proto.RegisterType((*GetFileAttributesResponse)(nil), "filer_pb.GetFileAttributesResponse")
proto.RegisterType((*GetEntryAttributesRequest)(nil), "filer_pb.GetEntryAttributesRequest")
proto.RegisterType((*GetEntryAttributesResponse)(nil), "filer_pb.GetEntryAttributesResponse")
proto.RegisterType((*GetFileContentRequest)(nil), "filer_pb.GetFileContentRequest")
proto.RegisterType((*GetFileContentResponse)(nil), "filer_pb.GetFileContentResponse")
proto.RegisterType((*CreateEntryRequest)(nil), "filer_pb.CreateEntryRequest")
@ -542,7 +542,7 @@ const _ = grpc.SupportPackageIsVersion4
type SeaweedFilerClient interface {
LookupDirectoryEntry(ctx context.Context, in *LookupDirectoryEntryRequest, opts ...grpc.CallOption) (*LookupDirectoryEntryResponse, error)
ListEntries(ctx context.Context, in *ListEntriesRequest, opts ...grpc.CallOption) (*ListEntriesResponse, error)
GetFileAttributes(ctx context.Context, in *GetFileAttributesRequest, opts ...grpc.CallOption) (*GetFileAttributesResponse, error)
GetEntryAttributes(ctx context.Context, in *GetEntryAttributesRequest, opts ...grpc.CallOption) (*GetEntryAttributesResponse, error)
GetFileContent(ctx context.Context, in *GetFileContentRequest, opts ...grpc.CallOption) (*GetFileContentResponse, error)
CreateEntry(ctx context.Context, in *CreateEntryRequest, opts ...grpc.CallOption) (*CreateEntryResponse, error)
SetFileChunks(ctx context.Context, in *SetFileChunksRequest, opts ...grpc.CallOption) (*SetFileChunksResponse, error)
@ -576,9 +576,9 @@ func (c *seaweedFilerClient) ListEntries(ctx context.Context, in *ListEntriesReq
return out, nil
}
func (c *seaweedFilerClient) GetFileAttributes(ctx context.Context, in *GetFileAttributesRequest, opts ...grpc.CallOption) (*GetFileAttributesResponse, error) {
out := new(GetFileAttributesResponse)
err := grpc.Invoke(ctx, "/filer_pb.SeaweedFiler/GetFileAttributes", in, out, c.cc, opts...)
func (c *seaweedFilerClient) GetEntryAttributes(ctx context.Context, in *GetEntryAttributesRequest, opts ...grpc.CallOption) (*GetEntryAttributesResponse, error) {
out := new(GetEntryAttributesResponse)
err := grpc.Invoke(ctx, "/filer_pb.SeaweedFiler/GetEntryAttributes", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
@ -635,7 +635,7 @@ func (c *seaweedFilerClient) AssignVolume(ctx context.Context, in *AssignVolumeR
type SeaweedFilerServer interface {
LookupDirectoryEntry(context.Context, *LookupDirectoryEntryRequest) (*LookupDirectoryEntryResponse, error)
ListEntries(context.Context, *ListEntriesRequest) (*ListEntriesResponse, error)
GetFileAttributes(context.Context, *GetFileAttributesRequest) (*GetFileAttributesResponse, error)
GetEntryAttributes(context.Context, *GetEntryAttributesRequest) (*GetEntryAttributesResponse, error)
GetFileContent(context.Context, *GetFileContentRequest) (*GetFileContentResponse, error)
CreateEntry(context.Context, *CreateEntryRequest) (*CreateEntryResponse, error)
SetFileChunks(context.Context, *SetFileChunksRequest) (*SetFileChunksResponse, error)
@ -683,20 +683,20 @@ func _SeaweedFiler_ListEntries_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
func _SeaweedFiler_GetFileAttributes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetFileAttributesRequest)
func _SeaweedFiler_GetEntryAttributes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetEntryAttributesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SeaweedFilerServer).GetFileAttributes(ctx, in)
return srv.(SeaweedFilerServer).GetEntryAttributes(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/filer_pb.SeaweedFiler/GetFileAttributes",
FullMethod: "/filer_pb.SeaweedFiler/GetEntryAttributes",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SeaweedFilerServer).GetFileAttributes(ctx, req.(*GetFileAttributesRequest))
return srv.(SeaweedFilerServer).GetEntryAttributes(ctx, req.(*GetEntryAttributesRequest))
}
return interceptor(ctx, in, info, handler)
}
@ -804,8 +804,8 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{
Handler: _SeaweedFiler_ListEntries_Handler,
},
{
MethodName: "GetFileAttributes",
Handler: _SeaweedFiler_GetFileAttributes_Handler,
MethodName: "GetEntryAttributes",
Handler: _SeaweedFiler_GetEntryAttributes_Handler,
},
{
MethodName: "GetFileContent",
@ -835,53 +835,53 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("filer.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 763 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x56, 0xdd, 0x6e, 0xd3, 0x4c,
0x10, 0xad, 0xeb, 0x24, 0x6d, 0x26, 0x69, 0xbf, 0x8f, 0x4d, 0xda, 0x9a, 0xf4, 0x2f, 0x2c, 0x2a,
0x2a, 0x42, 0xaa, 0x50, 0xb8, 0xe1, 0x92, 0xaa, 0x2d, 0x08, 0xa9, 0xa8, 0x92, 0xab, 0x22, 0x21,
0x24, 0xa2, 0xc4, 0x9e, 0x84, 0x55, 0x1d, 0x3b, 0x78, 0xd7, 0xa0, 0x72, 0xcd, 0xab, 0xf0, 0x18,
0xbc, 0x1b, 0xda, 0xf5, 0xc6, 0x5e, 0x37, 0x4e, 0xa1, 0x12, 0x77, 0xde, 0x99, 0x9d, 0x33, 0x67,
0x7e, 0xce, 0x26, 0xd0, 0x18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, 0x64, 0xc7, 0x08, 0x9c, 0xfb, 0x4d, 0xe8, 0xec, 0x2e, 0xf0, 0x66, 0x68, 0x9f, 0xe0, 0xc1,
0x9c, 0xaa, 0x09, 0xcd, 0xa3, 0x16, 0x3d, 0x2d, 0x9d, 0xc7, 0x77, 0xde, 0xc9, 0xf0, 0xaf, 0x60,
0xbd, 0x28, 0x56, 0xb2, 0x3f, 0x17, 0x58, 0x14, 0x7e, 0xa7, 0xbb, 0xf8, 0x82, 0xd9, 0x04, 0x43,
0x74, 0x66, 0x13, 0xe6, 0x65, 0x6e, 0x36, 0xa1, 0x4c, 0xa9, 0x4b, 0xc4, 0x85, 0xb5, 0xc2, 0x94,
0xc9, 0x5e, 0x1e, 0x51, 0xb6, 0x5b, 0x9d, 0xfd, 0x85, 0x7e, 0x93, 0xa1, 0x21, 0x4a, 0x93, 0xe1,
0xfc, 0xb3, 0x60, 0x32, 0x2c, 0x53, 0xf2, 0x12, 0xb9, 0x80, 0xa6, 0x29, 0x2e, 0x62, 0x04, 0x94,
0x68, 0xbc, 0xb3, 0xb7, 0xc8, 0x3d, 0x03, 0x1c, 0xd6, 0xd4, 0x7f, 0x9d, 0x17, 0xbf, 0x03, 0x00,
0x00, 0xff, 0xff, 0x2a, 0xc2, 0xff, 0xcb, 0xfa, 0x08, 0x00, 0x00,
// 765 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x56, 0xdd, 0x4e, 0xdb, 0x4a,
0x10, 0xc6, 0x38, 0x09, 0x64, 0x12, 0x38, 0x47, 0x93, 0x00, 0x3e, 0xe1, 0x2f, 0xc7, 0x2d, 0x15,
0x55, 0x25, 0x54, 0xa5, 0x37, 0xbd, 0x2c, 0x02, 0x8a, 0x2a, 0x51, 0x21, 0x19, 0x81, 0x54, 0xf5,
0x22, 0x4a, 0xec, 0x49, 0xba, 0xc2, 0xb1, 0x53, 0x7b, 0xdd, 0x8a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f3, 0x8a, 0x06, 0x5f, 0x89, 0x3c, 0xe1, 0x8d, 0x70, 0x0c, 0xed, 0xb2, 0xc7,
0x1d, 0x0f, 0xf2, 0xca, 0x0f, 0xfc, 0x9a, 0x74, 0x9e, 0xfd, 0x2e, 0x4c, 0x0d, 0x75, 0x09, 0x2f,
0xa0, 0xa1, 0x3d, 0xe5, 0xb8, 0xa3, 0x25, 0xce, 0xfd, 0x2a, 0x74, 0x76, 0x17, 0x78, 0xb3, 0x6a,
0x03, 0xc0, 0x79, 0x59, 0xe3, 0x93, 0x3c, 0x6d, 0xe1, 0xeb, 0xd2, 0x79, 0xfa, 0x70, 0x50, 0x06,
0x71, 0x0d, 0xeb, 0x45, 0xbd, 0xe2, 0x7e, 0x21, 0x73, 0x5e, 0xfb, 0x9d, 0xee, 0xe2, 0x00, 0xbd,
0x0f, 0x9a, 0xee, 0xf4, 0x3e, 0xcc, 0x2b, 0x5d, 0xef, 0x43, 0x99, 0x58, 0x97, 0xd0, 0x81, 0xb5,
0xc2, 0xa0, 0x71, 0x2f, 0xcf, 0x28, 0x5b, 0xaf, 0xce, 0xfe, 0x42, 0xbf, 0xce, 0x50, 0xd3, 0xa5,
0xce, 0x70, 0xfe, 0x65, 0xd0, 0x19, 0x96, 0x89, 0x79, 0x09, 0x2f, 0xa1, 0xa9, 0xeb, 0x0b, 0xb5,
0x84, 0x12, 0x99, 0x77, 0xf6, 0x16, 0xb9, 0x67, 0x05, 0x87, 0x35, 0xf9, 0x87, 0xe7, 0xd5, 0xaf,
0x00, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x51, 0xe7, 0x2b, 0xff, 0x08, 0x00, 0x00,
}

10
weed/server/filer_grpc_server.go

@ -59,11 +59,13 @@ func (fs *FilerServer) ListEntries(ctx context.Context, req *filer_pb.ListEntrie
return resp, nil
}
func (fs *FilerServer) GetFileAttributes(ctx context.Context, req *filer_pb.GetFileAttributesRequest) (*filer_pb.GetFileAttributesResponse, error) {
func (fs *FilerServer) GetEntryAttributes(ctx context.Context, req *filer_pb.GetEntryAttributesRequest) (*filer_pb.GetEntryAttributesResponse, error) {
attributes := &filer_pb.FuseAttributes{}
found, entry, err := fs.filer.FindEntry(filer2.NewFullPath(req.ParentDir, req.Name))
fullpath := filer2.NewFullPath(req.ParentDir, req.Name)
found, entry, err := fs.filer.FindEntry(fullpath)
if err != nil {
return nil, err
}
@ -77,7 +79,9 @@ func (fs *FilerServer) GetFileAttributes(ctx context.Context, req *filer_pb.GetF
attributes.Mtime = entry.Mtime.Unix()
}
return &filer_pb.GetFileAttributesResponse{
glog.V(0).Infof("GetEntryAttributes %v: %+v", fullpath, attributes)
return &filer_pb.GetEntryAttributesResponse{
Attributes: attributes,
}, nil
}

14
weed/server/filer_server_handlers_admin.go

@ -19,10 +19,24 @@ func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
writeJsonError(w, r, http.StatusInternalServerError, err)
return
}
uid, err := strconv.ParseUint(r.FormValue("uid"), 10, 64)
if err != nil && r.FormValue("uid") != "" {
glog.V(0).Infof("register %s to %s parse uid %s: %v", fileId, path, r.FormValue("uid"), err)
writeJsonError(w, r, http.StatusInternalServerError, err)
return
}
gid, err := strconv.ParseUint(r.FormValue("gid"), 10, 64)
if err != nil && r.FormValue("gid") != "" {
glog.V(0).Infof("register %s to %s parse gid %s: %v", fileId, path, r.FormValue("gid"), err)
writeJsonError(w, r, http.StatusInternalServerError, err)
return
}
entry := &filer2.Entry{
FullPath: filer2.FullPath(path),
Attr: filer2.Attr{
Mode: 0660,
Uid: uint32(uid),
Gid: uint32(gid),
},
Chunks: []*filer_pb.FileChunk{{
FileId: fileId,

Loading…
Cancel
Save