Changeset View
Standalone View
usr.sbin/fstyp/bfs.c
| /* | /* | ||||||||||||
| * Copyright (c) 2021 Miguel Gocobachi <miguel@gocobachi.dev>. All rights reserved. | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | ||||||||||||
0mp: It's not needed anymore.
Also, you may consider adding `SPDX-License-Identifier: BSD-2-Clause… | |||||||||||||
| * | * | ||||||||||||
| * Copyright (c) 2021 Miguel Gocobachi <miguel@gocobachi.dev> | |||||||||||||
| * | |||||||||||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||||||||||
| * modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||||||||||
| * are met: | * are met: | ||||||||||||
| * 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||||||||||
| * notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||||||||||
| * 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||||||||||
| * notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||||||||||
| * documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. | ||||||||||||
| Show All 15 Lines | |||||||||||||
| #include <stdint.h> | #include <stdint.h> | ||||||||||||
| #include <stdio.h> | #include <stdio.h> | ||||||||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||||||||
| #include <string.h> | #include <string.h> | ||||||||||||
| #include "fstyp.h" | #include "fstyp.h" | ||||||||||||
| #define BFS_OS_NAME_LENGTH 32 | #define BFS_OS_NAME_LENGTH 32 | ||||||||||||
pfgUnsubmitted Done Inline ActionsFWIW, there should be a <TAB> after #define. I can't check if that is a space or a tab, but it¿s a common mistake. pfg: FWIW, there should be a <TAB> after #define. I can't check if that is a space or a tab, but… | |||||||||||||
| #define BFS_SUPER_BLOCK_MAGIC1 0x42465331 | #define BFS_SUPER_BLOCK_MAGIC1 0x42465331 | ||||||||||||
| struct bfs_disk_superblock { | struct bfs_disk_superblock { | ||||||||||||
| char name[BFS_OS_NAME_LENGTH]; | char name[BFS_OS_NAME_LENGTH]; | ||||||||||||
| int32_t magic1; | int32_t magic1; | ||||||||||||
| }; | }; | ||||||||||||
Done Inline Actions
style(9) 0mp: style(9) | |||||||||||||
| int fstyp_bfs(FILE *fp, char *label, size_t size) | int | ||||||||||||
freebsd_igalic.coUnsubmitted Not Done Inline Actionswhy not return bool here? freebsd_igalic.co: why not return bool here? | |||||||||||||
miguel_gocobachi.devAuthorUnsubmitted Done Inline Actionsis it the standard? I am complete new collaborating with C code in an open source project, so I want to learn what is the best for FreeBSD src. miguel_gocobachi.dev: is it the standard? I am complete new collaborating with C code in an open source project, so I… | |||||||||||||
freebsd_igalic.coUnsubmitted Not Done Inline Actionsit is, and we use it. inconsistently https://reviews.freebsd.org/D29659 😅 freebsd_igalic.co: it is, and we use it. inconsistently https://reviews.freebsd.org/D29659 😅 | |||||||||||||
miguel_gocobachi.devAuthorUnsubmitted Done Inline ActionsI guess it will require more changes in all the files and the fstyp.c, I found this gem: error = fstyp_f(fp, label, sizeof(label)); if (error == 0) miguel_gocobachi.dev: I guess it will require more changes in all the files and the fstyp.c, I found this gem:
error… | |||||||||||||
freebsd_igalic.coUnsubmitted Not Done Inline Actionsif you have time and motivating you could just ignore my comment for now and instead do a cleanup revision freebsd_igalic.co: if you have time and motivating you could just ignore my comment for now and instead do a… | |||||||||||||
miguel_gocobachi.devAuthorUnsubmitted Done Inline Actionsthank you, I do have time and motivation! I will keep in mind this in future contributions, I would like to add the BFS support for the VFS/FS as well later on. miguel_gocobachi.dev: thank you, I do have time and motivation! I will keep in mind this in future contributions, I… | |||||||||||||
| fstyp_bfs(FILE *fp, char *label, size_t size) | |||||||||||||
| { | { | ||||||||||||
| struct bfs_disk_superblock *volume; | struct bfs_disk_superblock *volume; | ||||||||||||
| volume = read_buf(fp, 512, sizeof(*volume)); | volume = read_buf(fp, 512, sizeof(*volume)); | ||||||||||||
| if (volume == NULL) { | if (volume == NULL) { | ||||||||||||
Done Inline Actions
style(9) 0mp: style(9) | |||||||||||||
| free(volume); | free(volume); | ||||||||||||
| return 1; | return (1); | ||||||||||||
| } | } | ||||||||||||
| if (volume->magic1 != BFS_SUPER_BLOCK_MAGIC1) { | if (volume->magic1 != BFS_SUPER_BLOCK_MAGIC1) { | ||||||||||||
| free(volume); | free(volume); | ||||||||||||
| return 1; | return (1); | ||||||||||||
| } | } | ||||||||||||
| bzero(label, size); | bzero(label, size); | ||||||||||||
| strlcpy(label, volume->name, MIN(size, BFS_OS_NAME_LENGTH)); | strlcpy(label, volume->name, MIN(size, BFS_OS_NAME_LENGTH)); | ||||||||||||
| rtrim(label, size); | rtrim(label, size); | ||||||||||||
| free(volume); | free(volume); | ||||||||||||
| return 0; | return (0); | ||||||||||||
| } | } | ||||||||||||
It's not needed anymore.
Also, you may consider adding SPDX-License-Identifier: BSD-2-Clause-FreeBSD.