@@ -42,8 +42,8 @@ int create_mount_point(const char *path)
42
42
43
43
void perform_updates (const char * boot_mount , bool is_backup )
44
44
{
45
- if (chdir (boot_mount ) < 0 ) {
46
- ERROR ("Unable to change to '%s' directory. \n" , boot_mount );
45
+ if (chdir (boot_mount )) {
46
+ ERROR ("Unable to change to '%s' directory: %d \n" , boot_mount , errno );
47
47
return ;
48
48
}
49
49
@@ -53,20 +53,20 @@ void perform_updates(const char *boot_mount, bool is_backup)
53
53
54
54
DEBUG ("Remounting '%s' read-write\n" , boot_mount );
55
55
if (mount (NULL , boot_mount , NULL , MS_REMOUNT | MS_NOATIME , NULL )) {
56
- ERROR ("Unable to remount '%s' read-write. \n" , boot_mount );
56
+ ERROR ("Unable to remount '%s' read-write: %d \n" , boot_mount , errno );
57
57
return ;
58
58
}
59
59
60
60
if (update_modules ) {
61
- DEBUG ("Modules update found! \n" );
61
+ DEBUG ("Modules update found\n" );
62
62
rename ("modules.squashfs" , "modules.squashfs.bak" );
63
63
rename ("modules.squashfs.sha1" , "modules.squashfs.bak.sha1" );
64
64
rename ("update_m.bin" , "modules.squashfs" );
65
65
rename ("update_m.bin.sha1" , "modules.squashfs.sha1" );
66
66
}
67
67
68
68
if (update_rootfs ) {
69
- DEBUG ("RootFS update found! \n" );
69
+ DEBUG ("RootFS update found\n" );
70
70
71
71
/* If rootfs_bak was not passed, or the backup is not available,
72
72
* make a backup of the current rootfs before the update */
@@ -83,7 +83,7 @@ void perform_updates(const char *boot_mount, bool is_backup)
83
83
84
84
DEBUG ("Remounting '%s' read-only\n" , boot_mount );
85
85
if (mount (NULL , boot_mount , NULL , MS_REMOUNT | MS_RDONLY , NULL )) {
86
- ERROR ("Unable to remount '%s' read-only. \n" , boot_mount );
86
+ ERROR ("Unable to remount '%s' read-only: %d \n" , boot_mount , errno );
87
87
}
88
88
}
89
89
@@ -140,7 +140,7 @@ int main(int argc, char **argv, char **envp)
140
140
141
141
/* Mount the loop device that was just set up. */
142
142
if (mount (loop_dev , "/root" , ROOTFS_TYPE , MS_RDONLY , NULL )) {
143
- ERROR ("Failed to mount the rootfs image. \n" );
143
+ ERROR ("Failed to mount the rootfs image: %d \n" , errno );
144
144
return -1 ;
145
145
}
146
146
@@ -153,18 +153,18 @@ int main(int argc, char **argv, char **envp)
153
153
/* Move the devtmpfs mount to inside the rootfs tree. */
154
154
DEBUG ("Moving '/dev' mount\n" );
155
155
if (mount ("/dev" , "dev" , NULL , MS_MOVE , NULL )) {
156
- ERROR ("Unable to move the '/dev' mount. \n" );
156
+ ERROR ("Unable to move the '/dev' mount: %d \n" , errno );
157
157
return -1 ;
158
158
}
159
159
160
160
/* Re-open the console device at the new location. */
161
161
int fd = open ("dev/console" , O_RDWR , 0 );
162
162
if (fd < 0 ) {
163
- ERROR ("Unable to re-open console. \n" );
163
+ ERROR ("Unable to re-open console: %d \n" , fd );
164
164
return -1 ;
165
165
}
166
166
if (dup2 (fd , 0 ) != 0 || dup2 (fd , 1 ) != 1 || dup2 (fd , 2 ) != 2 ) {
167
- ERROR ("Unable to duplicate console handles. \n" );
167
+ ERROR ("Unable to duplicate console handles\n" );
168
168
return -1 ;
169
169
}
170
170
if (fd > 2 ) close (fd );
@@ -227,7 +227,7 @@ int main(int argc, char **argv, char **envp)
227
227
};
228
228
for (int i = 0 ; ; i ++ ) {
229
229
if (!inits [i ]) {
230
- ERROR ("Unable to find the 'init' executable. \n" );
230
+ ERROR ("Unable to find the 'init' executable\n" );
231
231
return -1 ;
232
232
}
233
233
if (!access (inits [i ], X_OK )) {
@@ -239,6 +239,6 @@ int main(int argc, char **argv, char **envp)
239
239
240
240
/* Execute the 'init' executable */
241
241
execvpe (argv [0 ], argv , envp );
242
- ERROR ("exec or init failed. \n" );
242
+ ERROR ("Exec of ' init' failed: %d \n" , errno );
243
243
return 0 ;
244
244
}
0 commit comments