Skip to content

Instantly share code, notes, and snippets.

@wmealing
Created June 10, 2014 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmealing/b94d462db8662a902e1a to your computer and use it in GitHub Desktop.
Save wmealing/b94d462db8662a902e1a to your computer and use it in GitHub Desktop.
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 25b1ebc..300f52d 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -155,11 +155,27 @@ static inline const char *get_task_state(struct task_struct *tsk)
return *p;
}
+static int count_open_files(struct fdtable *fdt)
+{
+ int fd = 0;
+ int count = 0;
+
+ if(!fdt)
+ return 0;
+
+ for (; fd < fdt->max_fds; fd++) {
+ if (FD_ISSET(fd, fdt->open_fds))
+ count++;
+ }
+
+ return count;
+}
+
static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *p)
{
struct group_info *group_info;
- int g;
+ int g, fdcount = 0;
struct fdtable *fdt = NULL;
const struct cred *cred;
pid_t ppid, tpid;
@@ -192,14 +208,22 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
task_utrace_proc_status(m, p);
task_lock(p);
- if (p->files)
+ if (p->files) {
+ spin_lock(&p->files->file_lock);
+
fdt = files_fdtable(p->files);
+ fdcount = count_open_files(fdt);
+
+ spin_unlock(&p->files->file_lock);
+ }
+
seq_printf(m,
"FDSize:\t%d\n"
+ "FDCount:\t%d\n"
"Groups:\t",
- fdt ? fdt->max_fds : 0);
- rcu_read_unlock();
+ fdt ? fdt->max_fds : 0, fdcount);
+ rcu_read_unlock();
group_info = cred->group_info;
task_unlock(p);
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index 2117b0e..2e2edd3 100644
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -14,7 +14,7 @@ Summary: The Linux kernel
# that the kernel isn't the stock distribution kernel, for example,
# by setting the define to ".local" or ".bz123456"
#
-# % define buildid .local
+%define buildid .whatever
%define distro_build %%BUILD%%
%define signmodules 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment