|
@@ -108,14 +108,14 @@ static int check_free_space(struct bsd_acct_struct *acct)
|
|
do_div(suspend, 100);
|
|
do_div(suspend, 100);
|
|
if (sbuf.f_bavail <= suspend) {
|
|
if (sbuf.f_bavail <= suspend) {
|
|
acct->active = 0;
|
|
acct->active = 0;
|
|
- printk(KERN_INFO "Process accounting paused\n");
|
|
|
|
|
|
+ pr_info("Process accounting paused\n");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
u64 resume = sbuf.f_blocks * RESUME;
|
|
u64 resume = sbuf.f_blocks * RESUME;
|
|
do_div(resume, 100);
|
|
do_div(resume, 100);
|
|
if (sbuf.f_bavail >= resume) {
|
|
if (sbuf.f_bavail >= resume) {
|
|
acct->active = 1;
|
|
acct->active = 1;
|
|
- printk(KERN_INFO "Process accounting resumed\n");
|
|
|
|
|
|
+ pr_info("Process accounting resumed\n");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -280,6 +280,7 @@ SYSCALL_DEFINE1(acct, const char __user *, name)
|
|
|
|
|
|
if (name) {
|
|
if (name) {
|
|
struct filename *tmp = getname(name);
|
|
struct filename *tmp = getname(name);
|
|
|
|
+
|
|
if (IS_ERR(tmp))
|
|
if (IS_ERR(tmp))
|
|
return PTR_ERR(tmp);
|
|
return PTR_ERR(tmp);
|
|
mutex_lock(&acct_on_mutex);
|
|
mutex_lock(&acct_on_mutex);
|
|
@@ -337,7 +338,7 @@ static comp_t encode_comp_t(unsigned long value)
|
|
return exp;
|
|
return exp;
|
|
}
|
|
}
|
|
|
|
|
|
-#if ACCT_VERSION==1 || ACCT_VERSION==2
|
|
|
|
|
|
+#if ACCT_VERSION == 1 || ACCT_VERSION == 2
|
|
/*
|
|
/*
|
|
* encode an u64 into a comp2_t (24 bits)
|
|
* encode an u64 into a comp2_t (24 bits)
|
|
*
|
|
*
|
|
@@ -350,7 +351,7 @@ static comp_t encode_comp_t(unsigned long value)
|
|
#define MANTSIZE2 20 /* 20 bit mantissa. */
|
|
#define MANTSIZE2 20 /* 20 bit mantissa. */
|
|
#define EXPSIZE2 5 /* 5 bit base 2 exponent. */
|
|
#define EXPSIZE2 5 /* 5 bit base 2 exponent. */
|
|
#define MAXFRACT2 ((1ul << MANTSIZE2) - 1) /* Maximum fractional value. */
|
|
#define MAXFRACT2 ((1ul << MANTSIZE2) - 1) /* Maximum fractional value. */
|
|
-#define MAXEXP2 ((1 <<EXPSIZE2) - 1) /* Maximum exponent. */
|
|
|
|
|
|
+#define MAXEXP2 ((1 << EXPSIZE2) - 1) /* Maximum exponent. */
|
|
|
|
|
|
static comp2_t encode_comp2_t(u64 value)
|
|
static comp2_t encode_comp2_t(u64 value)
|
|
{
|
|
{
|
|
@@ -381,7 +382,7 @@ static comp2_t encode_comp2_t(u64 value)
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-#if ACCT_VERSION==3
|
|
|
|
|
|
+#if ACCT_VERSION == 3
|
|
/*
|
|
/*
|
|
* encode an u64 into a 32 bit IEEE float
|
|
* encode an u64 into a 32 bit IEEE float
|
|
*/
|
|
*/
|
|
@@ -390,8 +391,9 @@ static u32 encode_float(u64 value)
|
|
unsigned exp = 190;
|
|
unsigned exp = 190;
|
|
unsigned u;
|
|
unsigned u;
|
|
|
|
|
|
- if (value==0) return 0;
|
|
|
|
- while ((s64)value > 0){
|
|
|
|
|
|
+ if (value == 0)
|
|
|
|
+ return 0;
|
|
|
|
+ while ((s64)value > 0) {
|
|
value <<= 1;
|
|
value <<= 1;
|
|
exp--;
|
|
exp--;
|
|
}
|
|
}
|
|
@@ -429,16 +431,17 @@ static void fill_ac(acct_t *ac)
|
|
run_time -= current->group_leader->start_time;
|
|
run_time -= current->group_leader->start_time;
|
|
/* convert nsec -> AHZ */
|
|
/* convert nsec -> AHZ */
|
|
elapsed = nsec_to_AHZ(run_time);
|
|
elapsed = nsec_to_AHZ(run_time);
|
|
-#if ACCT_VERSION==3
|
|
|
|
|
|
+#if ACCT_VERSION == 3
|
|
ac->ac_etime = encode_float(elapsed);
|
|
ac->ac_etime = encode_float(elapsed);
|
|
#else
|
|
#else
|
|
ac->ac_etime = encode_comp_t(elapsed < (unsigned long) -1l ?
|
|
ac->ac_etime = encode_comp_t(elapsed < (unsigned long) -1l ?
|
|
- (unsigned long) elapsed : (unsigned long) -1l);
|
|
|
|
|
|
+ (unsigned long) elapsed : (unsigned long) -1l);
|
|
#endif
|
|
#endif
|
|
-#if ACCT_VERSION==1 || ACCT_VERSION==2
|
|
|
|
|
|
+#if ACCT_VERSION == 1 || ACCT_VERSION == 2
|
|
{
|
|
{
|
|
/* new enlarged etime field */
|
|
/* new enlarged etime field */
|
|
comp2_t etime = encode_comp2_t(elapsed);
|
|
comp2_t etime = encode_comp2_t(elapsed);
|
|
|
|
+
|
|
ac->ac_etime_hi = etime >> 16;
|
|
ac->ac_etime_hi = etime >> 16;
|
|
ac->ac_etime_lo = (u16) etime;
|
|
ac->ac_etime_lo = (u16) etime;
|
|
}
|
|
}
|
|
@@ -491,12 +494,12 @@ static void do_acct_process(struct bsd_acct_struct *acct)
|
|
/* we really need to bite the bullet and change layout */
|
|
/* we really need to bite the bullet and change layout */
|
|
ac.ac_uid = from_kuid_munged(file->f_cred->user_ns, orig_cred->uid);
|
|
ac.ac_uid = from_kuid_munged(file->f_cred->user_ns, orig_cred->uid);
|
|
ac.ac_gid = from_kgid_munged(file->f_cred->user_ns, orig_cred->gid);
|
|
ac.ac_gid = from_kgid_munged(file->f_cred->user_ns, orig_cred->gid);
|
|
-#if ACCT_VERSION==1 || ACCT_VERSION==2
|
|
|
|
|
|
+#if ACCT_VERSION == 1 || ACCT_VERSION == 2
|
|
/* backward-compatible 16 bit fields */
|
|
/* backward-compatible 16 bit fields */
|
|
ac.ac_uid16 = ac.ac_uid;
|
|
ac.ac_uid16 = ac.ac_uid;
|
|
ac.ac_gid16 = ac.ac_gid;
|
|
ac.ac_gid16 = ac.ac_gid;
|
|
#endif
|
|
#endif
|
|
-#if ACCT_VERSION==3
|
|
|
|
|
|
+#if ACCT_VERSION == 3
|
|
ac.ac_pid = task_tgid_nr_ns(current, ns);
|
|
ac.ac_pid = task_tgid_nr_ns(current, ns);
|
|
rcu_read_lock();
|
|
rcu_read_lock();
|
|
ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent), ns);
|
|
ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent), ns);
|
|
@@ -530,6 +533,7 @@ void acct_collect(long exitcode, int group_dead)
|
|
|
|
|
|
if (group_dead && current->mm) {
|
|
if (group_dead && current->mm) {
|
|
struct vm_area_struct *vma;
|
|
struct vm_area_struct *vma;
|
|
|
|
+
|
|
down_read(¤t->mm->mmap_sem);
|
|
down_read(¤t->mm->mmap_sem);
|
|
vma = current->mm->mmap;
|
|
vma = current->mm->mmap;
|
|
while (vma) {
|
|
while (vma) {
|