From patchwork Sat Jul 6 13:49:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rodolfo_Garc=C3=ADa_Pe=C3=B1as_=28kix=29?= X-Patchwork-Id: 2824500 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 097A59F7D6 for ; Sat, 6 Jul 2013 13:56:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 172322012B for ; Sat, 6 Jul 2013 13:56:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BAF720166 for ; Sat, 6 Jul 2013 13:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751051Ab3GFN4l (ORCPT ); Sat, 6 Jul 2013 09:56:41 -0400 Received: from mail.kix.es ([46.105.17.89]:54732 "EHLO what.com.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404Ab3GFN4j (ORCPT ); Sat, 6 Jul 2013 09:56:39 -0400 Received: from osaka.kix.es (4.Red-217-127-226.staticIP.rima-tde.net [217.127.226.4]) by what.com.es (Postfix) with ESMTPA id CD9156A09BD; Sat, 6 Jul 2013 15:49:30 +0200 (CEST) From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= To: linux-pm@vger.kernel.org Cc: rjw@sisk.pl, =?UTF-8?q? "Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)" ?= Subject: [PATCH 2/7] This patch includes support for UUID tags. Date: Sat, 6 Jul 2013 15:49:11 +0200 Message-Id: <1373118556-27472-3-git-send-email-kix@kix.es> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373118556-27472-1-git-send-email-kix@kix.es> References: <1373118556-27472-1-git-send-email-kix@kix.es> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Rodolfo García Peñas (kix)" The new code detect if the resume device starts with the string "UUID=" and then convert the UUID to the /dev device. Signed-off-by: Rodolfo García Peñas (kix) --- Makefile.am | 2 ++ configure.ac | 11 +++++++++++ suspend.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/Makefile.am b/Makefile.am index 76a041d..4da1b4e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -69,11 +69,13 @@ AM_CFLAGS=\ -DS2RAM \ -D_LARGEFILE64_SOURCE \ $(LZO_CFLAGS) \ + $(LIBBLKID_LIBS_CFLAGS) \ $(LIBGCRYPT_CFLAGS) common_s2disk_libs=\ $(LZO_LIBS) \ $(LIBGCRYPT_LIBS) \ + $(LIBBLKID_LIBS) \ $(PTHREAD_LIBS) common_s2ram_libs= diff --git a/configure.ac b/configure.ac index 9172296..c973cf6 100644 --- a/configure.ac +++ b/configure.ac @@ -188,6 +188,17 @@ else AC_MSG_ERROR([Unsupported architecture ${host}]) fi +if test -z "${LIBBLKID_LIBS}"; then + AC_ARG_VAR([LIBBLKID_CFLAGS], [C compiler flags for libblkid]) + AC_ARG_VAR([LIBBLKID_LIBS], [linker flags for libblkid]) + AC_CHECK_LIB( + [blkid], + [blkid_new_probe], + [LIBBLKID_LIBS="-lblkid"], + [AC_MSG_ERROR([Required libblkid was not found])] + ) +fi + if test "${enable_compress}" = "yes"; then CONFIG_FEATURES="${CONFIG_FEATURES} compress" AC_DEFINE([CONFIG_COMPRESS], [1], [Define if compression enabled]) diff --git a/suspend.c b/suspend.c index 479ce58..56a99db 100644 --- a/suspend.c +++ b/suspend.c @@ -38,6 +38,7 @@ #ifdef CONFIG_COMPRESS #include #endif +#include #include "swsusp.h" #include "memalloc.h" @@ -229,6 +230,8 @@ static struct config_par parameters[] = { } }; +static char *fsprobe_get_devname_by_uuid(const char *uuid); + static loff_t check_free_swap(int dev) { int error; @@ -2414,6 +2417,21 @@ int main(int argc, char *argv[]) } ret = 0; + + /* If device is UUID, convert it to dev file */ + if (!strncmp(resume_dev_name, "UUID=", 5)) { + char *tmpdev = NULL; + + tmpdev = (char *) fsprobe_get_devname_by_uuid(resume_dev_name); + if (!tmpdev) { + ret = ENODEV; + goto Umount; + } + + snprintf(resume_dev_name, MAX_STR_LEN -1, "%s", tmpdev); + free(tmpdev); + } + if (stat(resume_dev_name, &stat_buf)) { suspend_error("Could not stat the resume device file."); ret = ENODEV; @@ -2561,3 +2579,17 @@ Umount: return ret; } + +static char *fsprobe_get_devname_by_uuid(const char *uuid) +{ + char *tmp_uuid = NULL, *ptr = NULL, *ret = NULL; + + tmp_uuid = strdup(uuid); + ptr = strtok(tmp_uuid, "="); /* string UUID */ + ptr = strtok(NULL, "="); /* UUID value */ + + if (ptr) + ret = blkid_evaluate_tag("UUID", ptr, NULL); + + return ret; +}