Skip to content

Commit

Permalink
cmd/clone: fix src mode check (#4856)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored and SandyXSD committed Jun 20, 2024
1 parent 4f002f9 commit dcd6efe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4212,14 +4212,15 @@ func (m *redisMeta) LoadMeta(r io.Reader) (err error) {
return err
}

func (m *redisMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string, ino Ino, attr *Attr, cmode uint8, cumask uint16, top bool) syscall.Errno {
func (m *redisMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string, ino Ino, originAttr *Attr, cmode uint8, cumask uint16, top bool) syscall.Errno {
return errno(m.txn(ctx, func(tx *redis.Tx) error {
a, err := tx.Get(ctx, m.inodeKey(srcIno)).Bytes()
if err != nil {
return err
}
m.parseAttr(a, attr)
if eno := m.Access(ctx, srcIno, MODE_MASK_R, attr); eno != 0 {
m.parseAttr(a, originAttr)
attr := *originAttr
if eno := m.Access(ctx, srcIno, MODE_MASK_R, &attr); eno != 0 {
return eno
}
attr.Parent = parent
Expand Down Expand Up @@ -4268,7 +4269,7 @@ func (m *redisMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name strin
}

_, err = tx.TxPipelined(ctx, func(p redis.Pipeliner) error {
p.Set(ctx, m.inodeKey(ino), m.marshal(attr), 0)
p.Set(ctx, m.inodeKey(ino), m.marshal(&attr), 0)
p.IncrBy(ctx, m.usedSpaceKey(), align4K(attr.Length))
p.Incr(ctx, m.totalInodesKey())
if len(srcXattr) > 0 {
Expand Down
9 changes: 5 additions & 4 deletions pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -3359,14 +3359,15 @@ func (m *kvMeta) LoadMeta(r io.Reader) error {
})
}

func (m *kvMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string, ino Ino, attr *Attr, cmode uint8, cumask uint16, top bool) syscall.Errno {
func (m *kvMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string, ino Ino, originAttr *Attr, cmode uint8, cumask uint16, top bool) syscall.Errno {
return errno(m.txn(func(tx *kvTxn) error {
a := tx.get(m.inodeKey(srcIno))
if a == nil {
return syscall.ENOENT
}
m.parseAttr(a, attr)
if eno := m.Access(ctx, srcIno, MODE_MASK_R, attr); eno != 0 {
m.parseAttr(a, originAttr)
attr := *originAttr
if eno := m.Access(ctx, srcIno, MODE_MASK_R, &attr); eno != 0 {
return eno
}
attr.Parent = parent
Expand Down Expand Up @@ -3416,7 +3417,7 @@ func (m *kvMeta) doCloneEntry(ctx Context, srcIno Ino, parent Ino, name string,
}
}

tx.set(m.inodeKey(ino), m.marshal(attr))
tx.set(m.inodeKey(ino), m.marshal(&attr))
prefix := m.xattrKey(srcIno, "")
tx.scan(prefix, nextKey(prefix), false, func(k, v []byte) bool {
tx.set(m.xattrKey(ino, string(k[len(prefix):])), v)
Expand Down

0 comments on commit dcd6efe

Please sign in to comment.