Re: [ANNOUNCE] util-linux v2.37-rc1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Karel Zak, le lun. 12 avril 2021 12:30:20 +0200, a ecrit:
> The util-linux release v2.37-rc1 is available at
>  
>   http://www.kernel.org/pub/linux/utils/util-linux/v2.37/

I am getting

/usr/bin/ld: schedutils/chrt.o: in function `show_sched_info':
/home/youpi/util-linux/schedutils/chrt.c:218: undefined reference to `proc_open_tasks'
/usr/bin/ld: /home/youpi/util-linux/schedutils/chrt.c:223: undefined reference to `proc_next_tid'
/usr/bin/ld: /home/youpi/util-linux/schedutils/chrt.c:226: undefined reference to `proc_close_tasks'
/usr/bin/ld: schedutils/chrt.o: in function `set_sched':
/home/youpi/util-linux/schedutils/chrt.c:324: undefined reference to `proc_open_tasks'
/usr/bin/ld: /home/youpi/util-linux/schedutils/chrt.c:329: undefined reference to `proc_next_tid'
/usr/bin/ld: /home/youpi/util-linux/schedutils/chrt.c:333: undefined reference to `proc_close_tasks'

/usr/bin/ld: login-utils/lslogins-lslogins.o: in function `get_nprocs':
/home/youpi/util-linux/login-utils/lslogins.c:591: undefined reference to `proc_open_processes'
/usr/bin/ld: /home/youpi/util-linux/login-utils/lslogins.c:593: undefined reference to `proc_processes_filter_by_uid'
/usr/bin/ld: /home/youpi/util-linux/login-utils/lslogins.c:595: undefined reference to `proc_next_pid'
/usr/bin/ld: /home/youpi/util-linux/login-utils/lslogins.c:598: undefined reference to `proc_close_processes'

I have attached a fix.

Samuel
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 5f950758b..660a1a95c 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -249,7 +249,9 @@ static const struct lslogins_coldesc coldescs[] =
 	[COL_PWD_CTIME_MIN] = { "PWD-MIN",	N_("number of days required between changes"), N_("Minimum change time"), 0.1, SCOLS_FL_RIGHT },
 	[COL_PWD_CTIME_MAX] = { "PWD-MAX",	N_("max number of days a password may remain unchanged"), N_("Maximum change time"), 0.1, SCOLS_FL_RIGHT },
 	[COL_SELINUX]       = { "CONTEXT",	N_("the user's security context"), N_("Selinux context"), 0.1 },
+#ifdef __linux__
 	[COL_NPROCS]        = { "PROC",         N_("number of processes run by the user"), N_("Running processes"), 1, SCOLS_FL_RIGHT },
+#endif
 };
 
 struct lslogins_control {
@@ -584,6 +586,7 @@ static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
 	return 0;
 }
 
+#ifdef __linux__
 static int get_nprocs(const uid_t uid)
 {
 	int nprocs = 0;
@@ -598,6 +601,7 @@ static int get_nprocs(const uid_t uid)
 	proc_close_processes(proc);
 	return nprocs;
 }
+#endif
 
 static const char *get_pwd_method(const char *str, const char **next, unsigned int *sz)
 {
@@ -888,9 +892,11 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
 				user->context = NULL;
 #endif
 			break;
+#ifdef __linux__
 		case COL_NPROCS:
 			xasprintf(&user->nprocs, "%d", get_nprocs(pwd->pw_uid));
 			break;
+#endif
 		default:
 			/* something went very wrong here */
 			err(EXIT_FAILURE, "fatal: unknown error");
@@ -1209,9 +1215,11 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri
 			rc = scols_line_set_data(ln, n, user->context);
 #endif
 			break;
+#ifdef __linux__
 		case COL_NPROCS:
 			rc = scols_line_set_data(ln, n, user->nprocs);
 			break;
+#endif
 		default:
 			/* something went very wrong here */
 			err(EXIT_FAILURE, _("internal error: unknown column"));
@@ -1622,7 +1630,9 @@ int main(int argc, char *argv[])
 
 	} else if (ncolumns == 2) {
 		/* default columns */
+#ifdef __linux__
 		add_column(columns, ncolumns++, COL_NPROCS);
+#endif
 		add_column(columns, ncolumns++, COL_PWDLOCK);
 		add_column(columns, ncolumns++, COL_PWDDENY);
 		add_column(columns, ncolumns++, COL_LAST_LOGIN);
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 052ad7a1b..b8890b3aa 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -214,6 +214,7 @@ fallback:
 static void show_sched_info(struct chrt_ctl *ctl)
 {
 	if (ctl->all_tasks) {
+#ifdef __linux__
 		pid_t tid;
 		struct proc_tasks *ts = proc_open_tasks(ctl->pid);
 
@@ -224,6 +225,9 @@ static void show_sched_info(struct chrt_ctl *ctl)
 			show_sched_pid_info(ctl, tid);
 
 		proc_close_tasks(ts);
+#else
+		err(EXIT_FAILURE, _("cannot obtain the list of tasks"));
+#endif
 	} else
 		show_sched_pid_info(ctl, ctl->pid);
 }
@@ -320,6 +324,7 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid)
 static void set_sched(struct chrt_ctl *ctl)
 {
 	if (ctl->all_tasks) {
+#ifdef __linux__
 		pid_t tid;
 		struct proc_tasks *ts = proc_open_tasks(ctl->pid);
 
@@ -331,7 +336,9 @@ static void set_sched(struct chrt_ctl *ctl)
 				err(EXIT_FAILURE, _("failed to set tid %d's policy"), tid);
 
 		proc_close_tasks(ts);
-
+#else
+		err(EXIT_FAILURE, _("cannot obtain the list of tasks"));
+#endif
 	} else if (set_sched_one(ctl, ctl->pid) == -1)
 		err(EXIT_FAILURE, _("failed to set pid %d's policy"), ctl->pid);
 

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux