]>
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"
18 #include <sys/types.h>
26 void dump_open_fds(CephContext
*cct
)
28 const char *fn
= PROCPREFIX
"/proc/self/fd";
31 lderr(cct
) << "dump_open_fds unable to open " << fn
<< dendl
;
34 struct dirent
*de
= nullptr;
37 while ((de
= ::readdir(d
))) {
38 if (de
->d_name
[0] == '.')
41 snprintf(path
, sizeof(path
), "%s/%s", fn
, de
->d_name
);
42 char target
[PATH_MAX
];
43 ssize_t r
= readlink(path
, target
, sizeof(target
) - 1);
46 lderr(cct
) << "dump_open_fds unable to readlink " << path
<< ": " << cpp_strerror(r
) << dendl
;
50 lderr(cct
) << "dump_open_fds " << de
->d_name
<< " -> " << target
<< dendl
;
53 lderr(cct
) << "dump_open_fds dumped " << n
<< " open files" << dendl
;