]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/fd.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2012 Inktank
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "include/compat.h"
19 void dump_open_fds(CephContext
*cct
)
21 const char *fn
= PROCPREFIX
"/proc/self/fd";
24 lderr(cct
) << "dump_open_fds unable to open " << fn
<< dendl
;
27 struct dirent
*de
= nullptr;
30 while ((de
= ::readdir(d
))) {
31 if (de
->d_name
[0] == '.')
34 snprintf(path
, sizeof(path
), "%s/%s", fn
, de
->d_name
);
35 char target
[PATH_MAX
];
36 ssize_t r
= readlink(path
, target
, sizeof(target
) - 1);
39 lderr(cct
) << "dump_open_fds unable to readlink " << path
<< ": " << cpp_strerror(r
) << dendl
;
43 lderr(cct
) << "dump_open_fds " << de
->d_name
<< " -> " << target
<< dendl
;
46 lderr(cct
) << "dump_open_fds dumped " << n
<< " open files" << dendl
;