Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/clone: fix src mode check #4856

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4135,14 +4135,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 @@ -4191,7 +4192,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 @@ -3398,14 +3398,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 @@ -3455,7 +3456,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
Loading