Commit 121a31ca authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

unix: Rename unlink_stale to unlink_sk

We gonna use it to detele not only stale
sockets but ghost sockets as well.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 53e47700
...@@ -1744,11 +1744,11 @@ static struct file_desc_ops unix_desc_ops = { ...@@ -1744,11 +1744,11 @@ static struct file_desc_ops unix_desc_ops = {
* Make FS clean from sockets we're about to * Make FS clean from sockets we're about to
* restore. See for how we bind them for details * restore. See for how we bind them for details
*/ */
static void unlink_stale(struct unix_sk_info *ui) static void unlink_sk(struct unix_sk_info *ui)
{ {
int ret, cwd_fd = -1, root_fd = -1, ns_fd = -1; int ret, cwd_fd = -1, root_fd = -1, ns_fd = -1;
if (ui->name[0] == '\0' || (ui->ue->uflags & USK_EXTERN)) if (!ui->name || ui->name[0] == '\0' || (ui->ue->uflags & USK_EXTERN))
return; return;
if (prep_unix_sk_cwd(ui, &cwd_fd, &root_fd, NULL)) if (prep_unix_sk_cwd(ui, &cwd_fd, &root_fd, NULL))
...@@ -1756,10 +1756,15 @@ static void unlink_stale(struct unix_sk_info *ui) ...@@ -1756,10 +1756,15 @@ static void unlink_stale(struct unix_sk_info *ui)
ret = unlinkat(AT_FDCWD, ui->name, 0) ? -1 : 0; ret = unlinkat(AT_FDCWD, ui->name, 0) ? -1 : 0;
if (ret < 0 && errno != ENOENT) { if (ret < 0 && errno != ENOENT) {
pr_warn("Can't unlink stale socket %#x peer %#x (name %s dir %s)\n", pr_warn("Can't unlink socket %#x peer %#x (name %s dir %s)\n",
ui->ue->ino, ui->ue->peer, ui->ue->ino, ui->ue->peer,
ui->name ? (ui->name[0] ? ui->name : &ui->name[1]) : "-", ui->name ? (ui->name[0] ? ui->name : &ui->name[1]) : "-",
ui->name_dir ? ui->name_dir : "-"); ui->name_dir ? ui->name_dir : "-");
} else if (ret == 0) {
pr_debug("Unlinked socket %#x peer %#x (name %s dir %s)\n",
ui->ue->ino, ui->ue->peer,
ui->name ? (ui->name[0] ? ui->name : &ui->name[1]) : "-",
ui->name_dir ? ui->name_dir : "-");
} }
revert_unix_sk_cwd(ui, &cwd_fd, &root_fd, &ns_fd); revert_unix_sk_cwd(ui, &cwd_fd, &root_fd, &ns_fd);
} }
...@@ -1774,8 +1779,7 @@ static int post_prepare_unix_sk(struct pprep_head *ph) ...@@ -1774,8 +1779,7 @@ static int post_prepare_unix_sk(struct pprep_head *ph)
ui = container_of(ph, struct unix_sk_info, peer_resolve); ui = container_of(ph, struct unix_sk_info, peer_resolve);
if (ui->ue->peer && fixup_unix_peer(ui)) if (ui->ue->peer && fixup_unix_peer(ui))
return -1; return -1;
if (ui->name) unlink_sk(ui);
unlink_stale(ui);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment