From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 30/35] [Suspend2] Filewriter parse resume2 parameter.
Date: Tue, 27 Jun 2006 08:40:46 +1000 [thread overview]
Message-ID: <20060626224045.4685.91165.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626223902.4685.52543.stgit@nigel.suspend2.net>
Parse a resume2= value to see if it is for the filewriter's use (file:
prefix or filewriter is the only writer registered), and whether it points
to a device we can open and a header we recognise.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/suspend_file.c | 116 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 116 insertions(+), 0 deletions(-)
diff --git a/kernel/power/suspend_file.c b/kernel/power/suspend_file.c
index 56de7d9..ee371ce 100644
--- a/kernel/power/suspend_file.c
+++ b/kernel/power/suspend_file.c
@@ -872,3 +872,119 @@ static void test_filewriter_target(void)
setting_filewriter_target = 0;
}
+/*
+ * Parse Image Location
+ *
+ * Attempt to parse a resume2= parameter.
+ * Swap Writer accepts:
+ * resume2=file:DEVNAME[:FIRSTBLOCK]
+ *
+ * Where:
+ * DEVNAME is convertable to a dev_t by name_to_dev_t
+ * FIRSTBLOCK is the location of the first block in the file.
+ * BLOCKSIZE is the logical blocksize >= SECTOR_SIZE & <= PAGE_SIZE,
+ * mod SECTOR_SIZE == 0 of the device.
+ * Data is validated by attempting to read a header from the
+ * location given. Failure will result in filewriter refusing to
+ * save an image, and a reboot with correct parameters will be
+ * necessary.
+ */
+
+static int filewriter_parse_sig_location(char *commandline, int only_writer)
+{
+ char *thischar, *devstart = NULL, *colon = NULL, *at_symbol = NULL;
+ int result = -EINVAL, target_blocksize = 0;
+
+ if (strncmp(commandline, "file:", 5)) {
+ if (!only_writer)
+ return 1;
+ } else
+ commandline += 5;
+
+ /*
+ * Don't check signature again if we're beginning a cycle. If we already
+ * did the initialisation successfully, assume we'll be okay when it comes
+ * to resuming.
+ */
+ if (filewriter_target_bdev)
+ return 0;
+
+ devstart = thischar = commandline;
+ while ((*thischar != ':') && (*thischar != '@') &&
+ ((thischar - commandline) < 250) && (*thischar))
+ thischar++;
+
+ if (*thischar == ':') {
+ colon = thischar;
+ *colon = 0;
+ thischar++;
+ }
+
+ while ((*thischar != '@') && ((thischar - commandline) < 250) && (*thischar))
+ thischar++;
+
+ if (*thischar == '@') {
+ at_symbol = thischar;
+ *at_symbol = 0;
+ }
+
+ /*
+ * For the filewriter, you can be able to resume, but not suspend,
+ * because the resume2= is set correctly, but the filewriter_target
+ * isn't.
+ *
+ * We may have come here as a result of setting resume2 or
+ * filewriter_target. We only test the filewriter target in the
+ * former case (it's already done in the later), and we do it before
+ * setting the block number ourselves. It will overwrite the values
+ * given on the command line if we don't.
+ */
+
+ if (!setting_filewriter_target)
+ __test_filewriter_target(filewriter_target, 1);
+
+ if (colon)
+ target_firstblock = (int) simple_strtoul(colon + 1, NULL, 0);
+ else
+ target_firstblock = 0;
+
+ if (at_symbol) {
+ target_blocksize = (int) simple_strtoul(at_symbol + 1, NULL, 0);
+ if (target_blocksize & (SECTOR_SIZE - 1)) {
+ printk("Filewriter: Blocksizes are multiples of %d.\n", SECTOR_SIZE);
+ result = -EINVAL;
+ goto out;
+ }
+ }
+
+ printk("Suspend2 Filewriter: Testing whether you can resume:\n");
+
+ filewriter_get_target_info(commandline, 0, 1);
+
+ if (!filewriter_target_bdev || IS_ERR(filewriter_target_bdev)) {
+ filewriter_target_bdev = NULL;
+ result = -1;
+ goto out;
+ }
+
+ if (target_blocksize)
+ set_devinfo(filewriter_target_bdev, ffs(target_blocksize));
+
+ result = __test_filewriter_target(commandline, 1);
+
+out:
+ if (result)
+ clear_suspend_state(SUSPEND_CAN_SUSPEND);
+ else
+ set_suspend_state(SUSPEND_CAN_SUSPEND);
+
+ printk("Resuming %sabled.\n", result ? "dis" : "en");
+
+ if (colon)
+ *colon = ':';
+ if (at_symbol)
+ *at_symbol = '@';
+
+ return result;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
next prev parent reply other threads:[~2006-06-26 22:54 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 22:39 [Suspend2][ 00/35] Filewriter Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 01/35] [Suspend2] Header file for suspend_file.c Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 02/35] [Suspend2] Filewriter set_devinfo patch Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 03/35] [Suspend2] Get filewriter storage available Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 04/35] [Suspend2] Does a filewriter page have contiguous blocks? Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 05/35] [Suspend2] Filewriter storage available less ignored pages Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 06/35] [Suspend2] Filewriter populate block list Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 07/35] [Suspend2] Filewriter cleanup Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 08/35] [Suspend2] Reopen the resume dev_t Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 09/35] [Suspend2] Get filewriter target info Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 10/35] [Suspend2] Parse filewriter signature Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 11/35] [Suspend2] Set the filewriter signature to say we have an image Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 12/35] [Suspend2] Get filewriter storage allocated Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 13/35] [Suspend2] Release allocated filewriter storage Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 14/35] [Suspend2] Allocate filewriter header storage Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 15/35] [Suspend2] Allocate filewriter storage Nigel Cunningham
2006-06-26 22:39 ` [Suspend2][ 16/35] [Suspend2] Filewriter header writing init/cleanup Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 17/35] [Suspend2] Filewriter initrd image support Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 18/35] [Suspend2] Header reading initialisation specific to files Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 19/35] [Suspend2] Filewriter header reading initialisation Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 20/35] [Suspend2] Filewriter image header read cleanup Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 21/35] [Suspend2] Make modifications to the filewriter signature Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 22/35] [Suspend2] Filewriter debug info routine Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 23/35] [Suspend2] Filewriter storage needed Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 24/35] [Suspend2] Invalidate filewriter image Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 25/35] [Suspend2] Does a filewriter image exist? Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 26/35] [Suspend2] Filewriter mark that attempted to resume Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 27/35] [Suspend2] Set filewriter resume2, having been given a filename Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 28/35] [Suspend2] Test filewriter target value helper Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 29/35] [Suspend2] Test filewriter target Nigel Cunningham
2006-06-26 22:40 ` Nigel Cunningham [this message]
2006-06-26 22:40 ` [Suspend2][ 31/35] [Suspend2] Serialise filewriter config in image header Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 32/35] [Suspend2] Filewriter initialise Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 33/35] [Suspend2] Filewriter proc data Nigel Cunningham
2006-06-26 22:40 ` [Suspend2][ 34/35] [Suspend2] Filewriter ops Nigel Cunningham
2006-06-26 22:41 ` [Suspend2][ 35/35] [Suspend2] Filewriter load/unload routines Nigel Cunningham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060626224045.4685.91165.stgit@nigel.suspend2.net \
--to=nigel@suspend2.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome