MCPcopy
hub / github.com/cubefs/cubefs / Link

Method Link

client/gosdk/cfs_client.go:1274–1306  ·  view source on GitHub ↗
(srcPath, dstPath string)

Source from the content-addressed store, hash-verified

1272}
1273
1274func (c *Client) Link(srcPath, dstPath string) error {
1275 fullSrcPath := c.absPath(srcPath)
1276 info, err := c.lookupPath(fullSrcPath)
1277 if err != nil {
1278 return err
1279 }
1280
1281 srcIno := info.Inode
1282 if !proto.IsRegular(info.Mode) {
1283 log.LogErrorf("Link: not regular, src_path(%s) src_ino(%v) mode(%v)\n", fullSrcPath, srcIno, proto.OsMode(info.Mode))
1284 return syscall.EPERM
1285 }
1286
1287 fullDstPath := c.absPath(dstPath)
1288 parentDir := gopath.Dir(fullDstPath)
1289 filename := gopath.Base(fullDstPath)
1290 info, err = c.lookupPath(parentDir)
1291 if err != nil {
1292 return err
1293 }
1294 parentIno := info.Inode
1295
1296 info, err = c.mw.Link(parentIno, filename, srcIno, fullDstPath)
1297 if err != nil {
1298 log.LogErrorf("Link: src_path(%s) src_ino(%v) dst_path(%s) parent(%v) err(%v)\n", fullSrcPath, srcIno, fullDstPath, parentIno, err)
1299 return err
1300 }
1301
1302 c.ic.Put(info)
1303 log.LogDebugf("Link: src_path(%s) src_ino(%v) dst_path(%s) dst_ino(%v) parent(%v)\n", fullSrcPath, srcIno, fullDstPath, info.Inode, parentIno)
1304
1305 return nil
1306}
1307
1308func (f *File) Fd() uint {
1309 return f.fd

Callers

nothing calls this directly

Calls 9

absPathMethod · 0.95
lookupPathMethod · 0.95
IsRegularFunction · 0.92
LogErrorfFunction · 0.92
OsModeFunction · 0.92
LogDebugfFunction · 0.92
DirMethod · 0.80
LinkMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected