Пример #1
0
/* Having a writeable /var is necessary for full system functioning.
 * If /var isn't writeable, we mount tmpfs over it. While this is
 * somewhat outside of ostree's scope, having all /var twiddling
 * in one place will make future maintenance easier.
 */
static void
maybe_mount_tmpfs_on_var (void)
{
  if (!path_is_on_readonly_fs ("/var"))
    return;

  if (umount ("/var") < 0 && errno != EINVAL)
    warn ("failed to unmount /var prior to mounting tmpfs, mounting over");

  if (mount ("tmpfs", "/var", "tmpfs", 0, NULL) < 0)
    err (EXIT_FAILURE, "failed to mount tmpfs on /var");
}
Пример #2
0
/* Having a writeable /var is necessary for full system functioning.
 * If /var isn't writeable, we mount tmpfs over it. While this is
 * somewhat outside of ostree's scope, having all /var twiddling
 * in one place will make future maintenance easier.
 */
static void
maybe_mount_tmpfs_on_var (void)
{
  if (!path_is_on_readonly_fs ("/var"))
    return;

  if (umount ("/var") < 0 && errno != EINVAL)
    {
      perror ("failed to unmount /var prior to mounting tmpfs, mounting over");
    }

  if (mount ("tmpfs", "/var", "tmpfs", 0, NULL) < 0)
    {
      perror ("failed to mount tmpfs on /var");
      exit (1);
    }
}
Пример #3
0
int
main(int argc, char *argv[])
{
  const char *remounts[] = { "/sysroot", "/etc", "/home", "/root", "/tmp", "/var", NULL };
  struct stat stbuf;
  int i;

  if (path_is_on_readonly_fs ("/"))
    {
      /* If / isn't writable, don't do any remounts; we don't want
       * to clear the readonly flag in that case.
       */

      maybe_mount_tmpfs_on_var ();

      exit (0);
    }

  for (i = 0; remounts[i] != NULL; i++)
    {
      const char *target = remounts[i];
      if (lstat (target, &stbuf) < 0)
        continue;
      /* Silently ignore symbolic links; we expect these to point to
       * /sysroot, and thus there isn't a bind mount there.
       */
      if (S_ISLNK (stbuf.st_mode))
        continue;
      if (mount (target, target, NULL, MS_REMOUNT | MS_SILENT, NULL) < 0)
	{
          /* Also ignore ENINVAL - if the target isn't a mountpoint
           * already, then assume things are OK.
           */
          if (errno != EINVAL)
            {
              perrorv ("failed to remount %s", target);
              exit (1);
            }
	}
    }

  maybe_mount_tmpfs_on_var ();

  exit (0);
}