• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • services
  • filewatch
raiselimit.cpp
Go to the documentation of this file.
1 #include <raiselimit.h>
2 #include <QString>
3 #include <QFile>
4 #include <QTextStream>
5 
6 using namespace KAuth;
7 
8 /* Make the new inotify limit persist across reboots by creating a file in /etc/sysctl.d
9  * Using /etc/sysctl.d is much easier than /etc/sysctl.conf, and should work
10  * on all systemd distros, debian (including derivatives such as ubuntu) and gentoo.
11  * This could potentially be a separate action, but that would require authenticating twice.
12  * Also, the user's file system isn't going away - if they wanted a larger limit once, they
13  * almost certainly want it again. */
14 bool raiselimitPermanently(int newLimit)
15 {
16  QFile sysctl("/etc/sysctl.d/97-kde-nepomuk-filewatch-inotify.conf");
17  //Just overwrite the existing file.
18  if( sysctl.open(QIODevice::WriteOnly) ){
19  QTextStream sysc(&sysctl);
20  sysc << "fs.inotify.max_user_watches = " << newLimit << "\n";
21  sysctl.close();
22  return true;
23  }
24  return false;
25 }
26 
27 ActionReply FileWatchHelper::raiselimit(QVariantMap args)
28 {
29  Q_UNUSED( args );
30  // Open the procfs file that controls the number of inotify user watches
31  QFile inotctl("/proc/sys/fs/inotify/max_user_watches");
32  if( !inotctl.open(QIODevice::ReadWrite) )
33  return ActionReply::HelperErrorReply;
34  QTextStream inot(&inotctl);
35  // Read the current number
36  QString curr = inot.readLine();
37  bool ok;
38  int now = curr.toInt(&ok);
39  if( !ok )
40  return ActionReply::HelperErrorReply;
41  // Write the new number, which is double the current number
42  int next = now*2;
43  // Check for overflow
44  if( next < now )
45  return ActionReply::HelperErrorReply;
46 
47  inot << next << "\n";
48  inotctl.close();
49  raiselimitPermanently(next);
50  return ActionReply::SuccessReply;
51 }
52 
53 KDE4_AUTH_HELPER_MAIN("org.kde.nepomuk.filewatch", FileWatchHelper)
FileWatchHelper
Definition: raiselimit.h:5
raiselimit.h
raiselimitPermanently
bool raiselimitPermanently(int newLimit)
Definition: raiselimit.cpp:14
FileWatchHelper::raiselimit
ActionReply raiselimit(QVariantMap args)
Definition: raiselimit.cpp:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal