@@ -40,20 +40,15 @@ int create_mount_point(const char *path)
40
40
return 0 ;
41
41
}
42
42
43
- void perform_updates (const char * boot_mount , bool is_backup )
43
+ void perform_updates (bool is_backup )
44
44
{
45
- if (chdir (boot_mount )) {
46
- ERROR ("Unable to change to '%s' directory: %d\n" , boot_mount , errno );
47
- return ;
48
- }
49
-
50
45
bool update_modules = !access ("update_m.bin" , R_OK );
51
46
bool update_rootfs = !access ("update_r.bin" , R_OK );
52
47
if (!update_modules && !update_rootfs ) return ;
53
48
54
- DEBUG ("Remounting '%s' read-write\n" , boot_mount );
55
- if (mount (NULL , boot_mount , NULL , MS_REMOUNT | MS_NOATIME , NULL )) {
56
- ERROR ("Unable to remount '%s' read-write: %d\n" , boot_mount , errno );
49
+ DEBUG ("Remounting boot device read-write\n" );
50
+ if (mount (NULL , "." , NULL , MS_REMOUNT | MS_NOATIME , NULL )) {
51
+ ERROR ("Unable to remount boot device read-write: %d\n" , errno );
57
52
return ;
58
53
}
59
54
@@ -81,9 +76,9 @@ void perform_updates(const char *boot_mount, bool is_backup)
81
76
82
77
sync ();
83
78
84
- DEBUG ("Remounting '%s' read-only\n" , boot_mount );
85
- if (mount (NULL , boot_mount , NULL , MS_REMOUNT | MS_RDONLY , NULL )) {
86
- ERROR ("Unable to remount '%s' read-only: %d\n" , boot_mount , errno );
79
+ DEBUG ("Remounting boot device read-only\n" );
80
+ if (mount (NULL , "." , NULL , MS_REMOUNT | MS_RDONLY , NULL )) {
81
+ ERROR ("Unable to remount boot device read-only: %d\n" , errno );
87
82
}
88
83
}
89
84
@@ -117,7 +112,12 @@ int main(int argc, char **argv, char **envp)
117
112
return -1 ;
118
113
}
119
114
120
- perform_updates (boot_mount , is_backup );
115
+ if (chdir (boot_mount )) {
116
+ ERROR ("Unable to change to '%s' directory: %d\n" , boot_mount , errno );
117
+ return -1 ;
118
+ }
119
+
120
+ perform_updates (is_backup );
121
121
122
122
/* Get free loop device. */
123
123
int devnr = logetfree ();
@@ -134,9 +134,7 @@ int main(int argc, char **argv, char **envp)
134
134
is_backup && !access (ROOTFS_BACKUP , F_OK )
135
135
? ROOTFS_BACKUP
136
136
: ROOTFS_CURRENT ;
137
- char rootfs_path [strlen (boot_mount ) + 1 + strlen (rootfs_img ) + 1 ];
138
- sprintf (rootfs_path , "%s/%s" , boot_mount , rootfs_img );
139
- losetup (loop_dev , rootfs_path );
137
+ losetup (loop_dev , rootfs_img );
140
138
141
139
/* Mount the loop device that was just set up. */
142
140
if (mount (loop_dev , "/root" , ROOTFS_TYPE , MS_RDONLY , NULL )) {
0 commit comments