Only bother with the first line of the files.
[util-vserver.git] / src / vsched.c
index bf6603f..358d139 100644 (file)
@@ -143,6 +143,8 @@ static void do_dir_entry(struct vc_set_sched *sched, const char *name)
   char buf[128];
   signed long val;
   struct sched_opt *opt;
+  ssize_t len;
+  char *newline;
 
   for (opt = FILE_OPTIONS; opt->name != 0; opt++) {
     if (strcmp(name, opt->name) == 0)
@@ -150,8 +152,11 @@ static void do_dir_entry(struct vc_set_sched *sched, const char *name)
   }
 
   fd = Eopen(name, O_RDONLY, 0);
-  Eread(fd, buf, sizeof(buf));
+  len = Eread(fd, buf, sizeof(buf)-1);
   Eclose(fd);
+  buf[len] = '\0';
+  if ((newline=strchr(buf, '\n')) != NULL)
+    *newline = '\0';
 
   if (!isNumber(buf, &val, true)) {
     WRITE_MSG(2, ENSC_WRAPPERS_PREFIX);
@@ -161,7 +166,7 @@ static void do_dir_entry(struct vc_set_sched *sched, const char *name)
   }
 
   if (opt->offset != offsetof(struct vc_set_sched, set_mask))
-    *(((char *)sched)+opt->offset) = (int_least32_t) val;
+    *(int_least32_t *)(((char *)sched)+opt->offset) = (int_least32_t) val;
 
   sched->set_mask |= opt->mask;
 }