}
static inline char *
-read_proc_cmdline_ostree (void)
+read_proc_cmdline_key (const char *key)
{
char *cmdline = NULL;
const char *iter;
char *ret = NULL;
+ size_t key_len = strlen (key);
cmdline = read_proc_cmdline ();
if (!cmdline)
const char *next_nonspc = next;
while (next_nonspc && *next_nonspc == ' ')
next_nonspc += 1;
- if (strncmp (iter, "ostree=", strlen ("ostree=")) == 0)
+ if (strncmp (iter, key, key_len) == 0 && iter[key_len] == '=')
{
- const char *start = iter + strlen ("ostree=");
+ const char *start = iter + key_len + 1;
if (next)
ret = strndup (start, next - start);
else
struct stat stbuf;
char *ostree_target, *deploy_path;
- ostree_target = read_proc_cmdline_ostree ();
+ ostree_target = read_proc_cmdline_key ("ostree");
if (!ostree_target)
errx (EXIT_FAILURE, "No OSTree target; expected ostree=/ostree/boot.N/...");
* exit so that we don't error, but at the same time work where switchroot
* is PID 1 (and so hasn't created /run/ostree-booted).
*/
- char *ostree_cmdline = read_proc_cmdline_ostree ();
+ char *ostree_cmdline = read_proc_cmdline_key ("ostree");
if (!ostree_cmdline)
exit (EXIT_SUCCESS);