Skip to content

Commit 9688ea9

Browse files
migrate: don't allow migrating more than once and if not migrated at boot
1 parent 6bb003c commit 9688ea9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

apps/migrate.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ int main(int argc, char * argv[]) {
140140

141141
hashmap_t * cmdline = get_cmdline();
142142

143+
if (fopen("/.migrated", "r")) {
144+
printf("You have already migrated the filesystem.\n");
145+
return 1;
146+
}
147+
148+
if (!hashmap_has(cmdline, "migrate")) {
149+
printf("Assuming you are trying to run migrate after the system has booted without migrating, this will break things!\n");
150+
printf("Please reboot the system with migrate in the cmdline.\n");
151+
return 1;
152+
}
153+
143154
if (hashmap_has(cmdline, "logtoserial")) {
144155
_debug = 1;
145156
}
@@ -191,5 +202,7 @@ int main(int argc, char * argv[]) {
191202
free(tmp);
192203
}
193204

205+
system("touch /.migrated");
206+
194207
return 0;
195208
}

0 commit comments

Comments
 (0)