Skip to content

Commit

Permalink
enhance: check for link (#4625)
Browse files Browse the repository at this point in the history
Signed-off-by: jiefenghuang <jiefeng@juicedata.io>
  • Loading branch information
jiefenghuang authored and SandyXSD committed Jun 19, 2024
1 parent a4a58f1 commit c42509b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pkg/meta/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,9 @@ func (m *baseMeta) Link(ctx Context, inode, parent Ino, name string, attr *Attr)
if name == "" {
return syscall.ENOENT
}
if name == "." || name == ".." {
return syscall.EEXIST
}

defer m.timeit("Link", time.Now())
if attr == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ func (m *redisMeta) doLink(ctx Context, inode, parent Ino, name string, attr *At
if pattr.Parent > TrashInode {
return syscall.ENOENT
}
if st := m.Access(ctx, parent, MODE_MASK_W, &pattr); st != 0 {
if st := m.Access(ctx, parent, MODE_MASK_W|MODE_MASK_X, &pattr); st != 0 {
return st
}
if pattr.Flags&FlagImmutable != 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ func (m *dbMeta) doLink(ctx Context, inode, parent Ino, name string, attr *Attr)
}
var pattr Attr
m.parseAttr(&pn, &pattr)
if st := m.Access(ctx, parent, MODE_MASK_W, &pattr); st != 0 {
if st := m.Access(ctx, parent, MODE_MASK_W|MODE_MASK_X, &pattr); st != 0 {
return st
}
if pn.Flags&FlagImmutable != 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ func (m *kvMeta) doLink(ctx Context, inode, parent Ino, name string, attr *Attr)
if pattr.Parent > TrashInode {
return syscall.ENOENT
}
if st := m.Access(ctx, parent, MODE_MASK_W, &pattr); st != 0 {
if st := m.Access(ctx, parent, MODE_MASK_W|MODE_MASK_X, &pattr); st != 0 {
return st
}
if pattr.Flags&FlagImmutable != 0 {
Expand Down

0 comments on commit c42509b

Please sign in to comment.