debian: Include ntfsprogs in the appliance.
[libguestfs.git] / HACKING
1 PLEASE LOOK AT THE TOP OF EACH FILE BEFORE EDITING TO SEE WHETHER IT
2 IS AUTOMATICALLY GENERATED OR NOT.
3
4 Adding a new action
5 ----------------------------------------------------------------------
6
7 All action functions are generated automatically, so there are only
8 two files you need to edit:
9
10 (1) generator/generator_actions.ml: Add your new action, parameters,
11 description, etc. to the big list at the top of this file.
12
13 (2) Edit/create a C file in daemon/ subdirectory which implements your
14 'do_action' function.  Take a look at one of the numerous examples
15 there.
16
17 Formatting
18 ----------------------------------------------------------------------
19
20 Try to use GNU / Emacs default formatting, following the convention
21 used elsewhere in the source.
22
23 Please make sure that the code compiles without warnings.
24
25 Please test any changes.
26
27 Useful targets:
28   make syntax-check    Checks the syntax of the C code.
29   make check           Runs the test suite.
30
31 Enable warnings, and fix any you find:
32   ./configure --enable-gcc-warnings
33
34 Code indentation
35 ----------------------------------------------------------------------
36 Our C source code generally adheres to some basic code-formatting
37 conventions.  The existing code base is not totally consistent on this
38 front, but we do prefer that contributed code be formatted similarly.
39 In short, use spaces-not-TABs for indentation, use 2 spaces for each
40 indentation level, and other than that, follow the K&R style.
41
42 If you use Emacs, add the following to one of one of your start-up files
43 (e.g., ~/.emacs), to help ensure that you get indentation right:
44
45   ;;; In libguestfs, indent with spaces everywhere (not TABs).
46   ;;; Exceptions: Makefile and ChangeLog modes.
47   (add-hook 'find-file-hook
48       '(lambda () (if (and buffer-file-name
49                            (string-match "/libguestfs\\>" (buffer-file-name))
50                            (not (string-equal mode-name "Change Log"))
51                            (not (string-equal mode-name "Makefile")))
52                       (setq indent-tabs-mode nil))))
53
54   ;;; When editing C sources in libguestfs, use this style.
55   (defun libguestfs-c-mode ()
56     "C mode with adjusted defaults for use with libguestfs."
57     (interactive)
58     (c-set-style "K&R")
59     (setq c-indent-level 2)
60     (setq c-basic-offset 2))
61   (add-hook 'c-mode-hook
62             '(lambda () (if (string-match "/libguestfs\\>" (buffer-file-name))
63                             (libguestfs-c-mode))))
64
65 Directories
66 ----------------------------------------------------------------------
67
68 appliance/
69         The qemu appliance, build scripts and so on.
70
71 capitests/
72         Automated tests of the C API.
73
74 cat/
75         The 'virt-cat', 'virt-filesystems' and 'virt-ls' commands and
76         documentation.
77
78 contrib/
79         Outside contributions, experimental parts.
80
81 csharp/
82         Experimental C# bindings.
83
84 daemon/
85         The daemon that runs inside the guest and carries out actions.
86
87 examples/
88         The examples.
89
90 fish/
91         Guestfish (the command-line program / shell)
92
93 fuse/
94         FUSE (userspace filesystem) built on top of libguestfs.
95
96 generator/
97         The crucially important generator, used to automatically
98         generate large amounts of boilerplate C code for things like
99         RPC and bindings.
100
101 haskell/
102         Haskell bindings.
103
104 hivex/ [removed in 1.0.85]
105        This used to contain the hivex library for reading and
106        writing Windows Registry binary hive files.  This is now
107        available as a separate upstream project.
108
109 images/
110         Some guest images to test against.  These are gzipped to save
111         space.  You have to unzip them before use.
112
113         Also contains some files used by the test suite.
114
115 inspector/
116         Virtual machine image inspector (virt-inspector).
117
118 java/
119         Java bindings.
120
121 m4/
122         M4 macros used by autoconf.
123
124 ocaml/
125         OCaml bindings.
126
127 php/
128         PHP bindings.
129
130 po/
131         Translations of simple gettext strings.  For translations of
132         longer documents, see po-docs/.
133
134 po-docs/
135         The build infrastructure and PO files for translations of
136         manpages and POD files.  Eventually this will be combined
137         with the po/ directory, but that is rather complicated.
138
139 perl/
140         Perl bindings.
141
142 python/
143         Python bindings.
144
145 regressions/
146         Regression tests.
147
148 ruby/
149         Ruby bindings.
150
151 tools/
152         Command line tools like virt-df, virt-edit and more.
153
154 src/
155         Source code to the C library.
156
157 test-tool/
158         Interactive qemu/kernel test tool.
159
160 Debugging
161 ----------------------------------------------------------------------
162
163 It's a good idea to use guestfish to try out new commands.
164
165 Debugging the daemon is a problem because it runs inside a minimal
166 qemu environment.  However you can print messages from the daemon, and
167 they will show up if you use 'guestfish -v'.
168
169 Patches
170 ----------------------------------------------------------------------
171
172 Submit patches to the mailing list:
173 http://www.redhat.com/mailman/listinfo/libguestfs
174 and CC to rjones@redhat.com
175
176 I18N
177 ----------------------------------------------------------------------
178
179 We support i18n (gettext anyhow) in the library.
180
181 However many messages come from the daemon, and we don't translate
182 those at the moment.  One reason is that the appliance generally has
183 all locale files removed from it, because they take up a lot of space.
184 So we'd have to readd some of those, as well as copying our PO files
185 into the appliance.
186
187 Debugging messages are never translated, since they are intended for
188 the programmers.
189
190 Extended printf
191 ----------------------------------------------------------------------
192
193 In the daemon code we have created custom printf formatters %Q and %R,
194 which are used to do shell quoting.
195
196 %Q => Simple shell quoted string.  Any spaces or other shell characters
197       are escaped for you.
198
199 %R => Same as %Q except the string is treated as a path which is prefixed
200       by the sysroot.
201
202 eg.
203
204 asprintf (&cmd, "cat %R", path);
205 ==> "cat /sysroot/some\ path\ with\ spaces"
206
207 Note: Do NOT use these when you are passing parameters to the
208 command{,r,v,rv}() functions.  These parameters do NOT need to be
209 quoted because they are not passed via the shell (instead, straight to
210 exec).  You probably want to use the sysroot_path() function however.