📄 white-paper.texi
字号:
@node White Paper, Reference Manual, About, Top@chapter LibGTop White Paper@menu* Introduction:: Introduction* Overview:: Overview@end menu@node Introduction, Overview, White Paper, White Paper@section IntroductionMany modern UNIX systems like Solaris, BSD or Digitial Unix only allowpriviledged processes to read information like CPU and Memory Usage orinformation about running processes.@itemize @bullet@itemBSD, for instance, doesn't have any other way to get those data than readingdirectly from @file{/dev/kmem} and you need to be in the @code{kmem} group tobe able to read this.@itemOther systems, like Digital Unix, allow all users to get things like CPU andMemory statistics, but only root may read information about any process otherthan the current one (you may not even get information about your own processesif you're not root).@itemLinux has a very nice @file{/proc} filesystem, but reading and parsing@file{/proc} is very slow and inefficient.@itemSolaris is a bit better, but you still need to be in the @code{sys} group oreven root to get some data.@end itemizeBecause of this system utilities like @code{ps}, @code{uptime} or @code{top}often are setgid kmem or setuid root. Usually, they're also very specific tothe system they're written for and not easily portable to other systems withouta lot of work.This, of cause, becomes a problem for graphical tools like @code{gtop} - makinga GTK+ program setgid or even setuid would be a security hole as big as you candrive the entire X11 source code through. For the GNOME project, we also neededsome kind of library which provides all the required information in a portablesince there's more than just one single program that wants to use them - forinstance @code{gtop} and the @code{multiload}, @code{cpumemusage} and@code{netload} panel applets.@node Overview, , Introduction, White Paper@section OverviewThis section should give you a short overview on how LibGTop was developed, whichthings needed to be considered and how it works.@menu* Interface Design:: Things that need to be considered* Server Implementation:: The LibGTop "server"@end menu@node Interface Design, Server Implementation, Overview, Overview@subsection Interface DesignAt the very beginning, it was necessary to collect all the data the library partshould provide and put them into some C structures. This was not that easiy as itmight sound since LibGTop should be portable to any modern UNIX system with a commonlibrary part on all those systems, but the data that should be returned vary fromsystem to system. For instance some systems support shared memory, but some othersmay not.The header files where we define these C structures (which are system-independent) areshared between client and server. This way we can call the system dependent codedirectly where we do not need any special privileges to do so.All of those structures contain a @code{flags} member which is interpreted as a bitmask and tells the caller of the library functions which of the fields in the returnedstructure are valid and which are not.@node Server Implementation, , Interface Design, Overview@subsection Server ImplementationThe LibGTop @dfn{server} is a setgid/setuid binary which contains all the systemdependent code which needs special privileges. It is only build if it's requiredon the current system (for instance, the Linux kernel provides all the requireddata via its @file{/proc} filesystem so we do not need the server at all) and itonly contains the @dfn{features} which need privileges.Whenever we do not need any privileges to get all the data for some of the requestedstructures (here called @dfn{features}) the library calls the sysdeps code directlyrather than using the server.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -