add packaging
[platform/upstream/e2fsprogs.git] / packaging / e2fsprogs-1.41.1-splash_support.patch
1 Index: e2fsck/Makefile.in
2 ===================================================================
3 --- e2fsck/Makefile.in.orig     2012-06-04 18:49:33.000000000 +0200
4 +++ e2fsck/Makefile.in  2012-06-14 09:50:56.344425761 +0200
5 @@ -68,7 +68,7 @@ OBJS= crc32.o dict.o unix.o e2fsck.o sup
6         pass3.o pass4.o pass5.o journal.o badblocks.o util.o dirinfo.o \
7         dx_dirinfo.o ehandler.o problem.o message.o quota.o recovery.o \
8         region.o revoke.o ea_refcount.o rehash.o profile.o prof_err.o \
9 -       logfile.o sigcatcher.o $(MTRACE_OBJ)
10 +       logfile.o sigcatcher.o splash.o $(MTRACE_OBJ)
11  
12  PROFILED_OBJS= profiled/dict.o profiled/unix.o profiled/e2fsck.o \
13         profiled/super.o profiled/pass1.o profiled/pass1b.o \
14 @@ -107,6 +107,7 @@ SRCS= $(srcdir)/e2fsck.c \
15         $(srcdir)/rehash.c \
16         $(srcdir)/region.c \
17         $(srcdir)/profile.c \
18 +       $(srcdir)/splash.c \
19         $(srcdir)/sigcatcher.c \
20         $(srcdir)/logfile.c \
21         prof_err.c \
22 @@ -539,6 +540,7 @@ region.o: $(srcdir)/region.c $(top_build
23   $(srcdir)/profile.h prof_err.h $(top_srcdir)/lib/quota/mkquota.h \
24   $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \
25   $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h
26 +splash.o: $(srcdir)/splash.c $(srcdir)/splash.h
27  profile.o: $(srcdir)/profile.c $(top_builddir)/lib/config.h \
28   $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/et/com_err.h \
29   $(srcdir)/profile.h prof_err.h
30 Index: e2fsck/splash.c
31 ===================================================================
32 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
33 +++ e2fsck/splash.c     2012-06-14 09:50:21.834048298 +0200
34 @@ -0,0 +1,100 @@
35 +/*
36 + * add support for switching the splash screen on boot
37 + */
38 +#include <stdio.h>
39 +#include <string.h>
40 +#include <sys/types.h>
41 +#include <sys/stat.h>
42 +#include <fcntl.h>
43 +#include <unistd.h>
44 +#include <errno.h>
45 +#include "splash.h"
46 +
47 +static int verbose = 0;
48 +
49 +/* nop implementation
50 + */
51 +static void nop(void)
52 +{
53 +}
54 +
55 +static struct splash_ops nop_ops = {
56 +       .splash_on = nop,
57 +       .splash_off = nop
58 +};
59 +
60 +/*
61 + *  bootsplash implementation
62 + */
63 +#define BOOTSPLASH_CTL "/proc/splash"
64 +
65 +static int bootsplash_exists(void)
66 +{
67 +       struct stat sb;
68 +
69 +       if (stat(BOOTSPLASH_CTL, &sb) == -1)
70 +               return 0;
71 +
72 +       if (S_ISREG(sb.st_mode))
73 +               return 1;
74 +
75 +       return 0;
76 +}
77 +
78 +/* write msg to splash control */
79 +static void bootsplash_msg(const char *msg, size_t size)
80 +{
81 +       int fd;
82 +       size_t written;
83 +
84 +       fd = open(BOOTSPLASH_CTL, O_WRONLY);
85 +       if (fd == -1) {
86 +               if (verbose)
87 +                       printf("cannot open %s\n", BOOTSPLASH_CTL);
88 +               return;
89 +       }
90 +
91 +       written = write(fd, msg, size);
92 +       if (written != size) {
93 +               if (verbose)
94 +                       printf("size = %i, written = %i\n", size, written);
95 +       }
96 +
97 +       close(fd);
98 +}
99 +
100 +static void bootsplash_on(void)
101 +{
102 +       if (verbose)
103 +               printf("setting bootsplash silent\n");
104 +       bootsplash_msg("silent\n", 7);
105 +}
106 +
107 +static void bootsplash_off(void)
108 +{
109 +       if (verbose)
110 +               printf("setting bootsplash verbose\n");
111 +       bootsplash_msg("verbose\n", 8);
112 +}
113 +
114 +static struct splash_ops bootsplash_ops = {
115 +       .splash_on = bootsplash_on,
116 +       .splash_off = bootsplash_off
117 +};
118 +
119 +/*
120 + * Initialisation
121 + */
122 +void splash_init(struct splash_ops **ops)
123 +{
124 +       if (bootsplash_exists())
125 +               *ops = &bootsplash_ops;
126 +       else
127 +               *ops = &nop_ops;
128 +}
129 +
130 +void splash_set_verbose(void)
131 +{
132 +       verbose = 1;
133 +}
134 +
135 Index: e2fsck/splash.h
136 ===================================================================
137 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
138 +++ e2fsck/splash.h     2012-06-14 09:50:21.834048298 +0200
139 @@ -0,0 +1,13 @@
140 +#ifndef _SPLASH_H
141 +#define _SPLASH_H
142 +
143 +struct splash_ops {
144 +       void (*splash_on)(void);
145 +       void (*splash_off)(void);
146 +};
147 +
148 +void splash_init(struct splash_ops **ops);
149 +void splash_set_verbose(void);
150 +
151 +#endif /* _SPLASH_H */
152 +
153 Index: e2fsck/unix.c
154 ===================================================================
155 --- e2fsck/unix.c.orig  2012-06-12 04:12:50.000000000 +0200
156 +++ e2fsck/unix.c       2012-06-14 09:50:21.834048298 +0200
157 @@ -51,6 +51,7 @@ extern int optind;
158  #include "e2p/e2p.h"
159  #include "e2fsck.h"
160  #include "problem.h"
161 +#include "splash.h"
162  #include "../version.h"
163  
164  /* Command line options */
165 @@ -1141,6 +1142,7 @@ int main (int argc, char *argv[])
166         __u32 features[3];
167         char *cp;
168         int qtype;  /* quota type */
169 +       struct splash_ops *sops;
170  
171         clear_problem_context(&pctx);
172         sigcatcher_setup();
173 @@ -1172,6 +1174,7 @@ int main (int argc, char *argv[])
174                 exit(FSCK_ERROR);
175         }
176         reserve_stdio_fds();
177 +       splash_init(&sops);
178  
179         set_up_logging(ctx);
180         if (ctx->logf) {
181 @@ -1548,6 +1551,7 @@ print_unsupp_features:
182                 fatal_error(ctx, 0);
183         check_if_skip(ctx);
184         check_resize_inode(ctx);
185 +       sops->splash_off();
186         if (bad_blocks_file)
187                 read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks);
188         else if (cflag)