Re: Back to the future.

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

 



Hi!

> I'd really suggest _just_ the "full image". Nothing else is probably ever 
> worth supporting. Your "snapshot to disk" wouldn't be _quite_ as simple as 
> "echo disk > /sys/power/state", but it should not necessarily be much 
> worse than
> 
> 	snapshot_kernel | gzip -9 > /dev/snapshot

Yep, we "freeze too much", so we can't just use the shell and pipe
it. Too bad.

  218 int write_image(char *resume_dev_name)
  219 {
  220 	static struct swap_map_handle handle;
  221 	struct swsusp_info *header;
  222 	unsigned long start;
  223 	int fd;
  224 	int error;
  225 
  226 	fd = open(resume_dev_name, O_RDWR | O_SYNC);
  227 	if (fd < 0) {
  228 		printf("suspend: Could not open resume device\n");
  229 		return error;
  230 	}
  231 	error = read(dev, buffer, PAGE_SIZE);
  232 	if (error < PAGE_SIZE)
  233 		return error < 0 ? error : -EFAULT;
  234 	header = (struct swsusp_info *)buffer;
  235 	if (!enough_swap(header->pages)) {
  236 		printf("suspend: Not enough free swap\n");
  237 		return -ENOSPC;
  238 	}
  239 	error = init_swap_writer(&handle, fd);
  240 	if (!error) {
  241 		start = handle.cur_swap;
  242 		error = swap_write_page(&handle, header);
  243 	}
  244 	if (!error)
  245 		error = save_image(&handle, header->pages - 1);
  246 	if (!error) {
  247 		flush_swap_writer(&handle);
  248 		printf( "S" );
  249 		error = mark_swap(fd, start);
  250 		printf( "|\n" );
  251 	}
  252 	fsync(fd);
  253 	close(fd);
  254 	return error;
  255 }

This is basically the loop above, made complex by the fact that we do
not want to have separate partition for snapshot; we just want to
reuse free space in swap partition.

I think you've just invented uswsusp.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux