desktop/unx/source/pagein.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
New commits: commit a42169cdae80f88e1c4b52c333e928d239d917f5 Author: Nurhak ALTIN <[email protected]> Date: Sun May 1 10:45:30 2016 +0300 tdf#99311 Detect SSDs in pagein Avoid doing the pagein work if we can detect a non-rotational disk. Change-Id: I1ce11050d7ed2a805568343cd385f2612d7c8939 Reviewed-on: https://gerrit.libreoffice.org/24560 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Meeks <[email protected]> diff --git a/desktop/unx/source/pagein.c b/desktop/unx/source/pagein.c index 7db52d8..03b26dc 100644 --- a/desktop/unx/source/pagein.c +++ b/desktop/unx/source/pagein.c @@ -24,6 +24,8 @@ #include <errno.h> #include <stdio.h> #include <string.h> +#include <sys/stat.h> +#include <sys/types.h> /* do_pagein */ static void do_pagein (const char * filename) @@ -42,11 +44,38 @@ static void do_pagein (const char * filename) file_image_close (&image); } +int isRotational(char const * path) +{ +#ifdef LINUX + FILE * fp = NULL; + char fullpath[4096]; + struct stat out; + int major, minor; + char type; + if( !stat( path , &out ) == 0) + return 1; + major = major(out.st_dev); + minor = 0; /* minor(out.st_dev); only the device itself has a queue */ + sprintf(fullpath,"/sys/dev/block/%d:%d/queue/rotational",major,minor); + if ((fp = fopen (fullpath, "r"))) + { + if (fgets(&type, 1, fp)) + { + fclose(fp); + return type == '1'; + } + } +#endif + return 1; +} + void pagein_execute(char const * path, char const * file) { char fullpath[4096]; char *p = NULL; FILE * fp = NULL; + if(!isRotational(path)) + return; memset(fullpath, 0, sizeof(fullpath)); strncpy (fullpath, path, 3000); if (!(p = strrchr (fullpath, '/'))) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
