MCPcopy Create free account
hub / github.com/ceph/ceph / clean_dir

Method clean_dir

src/client/SyntheticClient.cc:1541–1578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1539
1540
1541int SyntheticClient::clean_dir(string& basedir)
1542{
1543 // read dir
1544 list<string> contents;
1545 UserPerm perms = client->pick_my_perms();
1546 int r = client->getdir(basedir.c_str(), contents, perms);
1547 if (r < 0) {
1548 dout(1) << "getdir on " << basedir << " returns " << r << dendl;
1549 return r;
1550 }
1551
1552 for (list<string>::iterator it = contents.begin();
1553 it != contents.end();
1554 ++it) {
1555 if (*it == ".") continue;
1556 if (*it == "..") continue;
1557 string file = basedir + "/" + *it;
1558
1559 if (time_to_stop()) break;
1560
1561 struct stat st;
1562 int r = client->lstat(file.c_str(), &st, perms);
1563 if (r < 0) {
1564 dout(1) << "stat error on " << file << " r=" << r << dendl;
1565 continue;
1566 }
1567
1568 if ((st.st_mode & S_IFMT) == S_IFDIR) {
1569 clean_dir(file);
1570 client->rmdir(file.c_str(), perms);
1571 } else {
1572 client->unlink(file.c_str(), perms);
1573 }
1574 }
1575
1576 return 0;
1577
1578}
1579
1580
1581int SyntheticClient::full_walk(string& basedir)

Callers

nothing calls this directly

Calls 8

pick_my_permsMethod · 0.80
getdirMethod · 0.80
c_strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
lstatMethod · 0.45
rmdirMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected