From patchwork Wed Mar 6 21:51:48 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: 2228331 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3B1DA3FC8A for ; Wed, 6 Mar 2013 21:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751757Ab3CFVwO (ORCPT ); Wed, 6 Mar 2013 16:52:14 -0500 Received: from ks399202.kimsufi.com ([37.59.37.136]:36437 "EHLO ks399202.kimsufi.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752951Ab3CFVwN (ORCPT ); Wed, 6 Mar 2013 16:52:13 -0500 Received: from kentin.kix.es (4.Red-217-127-226.staticIP.rima-tde.net [217.127.226.4]) by ks399202.kimsufi.com (mail) with ESMTPSA id 2FA242F818FC; Wed, 6 Mar 2013 22:58:21 +0100 (CET) From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= To: linux-pm@vger.kernel.org Cc: =?UTF-8?q? "Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)" ?= Subject: [PATCH 1/3] UUID support Date: Wed, 6 Mar 2013 22:51:48 +0100 Message-Id: <1362606710-18089-2-git-send-email-kix@kix.es> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1362606710-18089-1-git-send-email-kix@kix.es> References: <1362606710-18089-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 From: "Rodolfo García Peñas (kix)" This patch includes support for UUID tags. 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..3924532 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; +}