X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=fs%2Fzfs%2Fzfs.c;h=818d3d926d2a3a349ac2e96bef28bc93e24b49cf;hb=7b48d8c8bc40ba3215a5ceb2731d762d4b143e3b;hp=360f723c846b9449da97d7853d54a0472590112f;hpb=4d3c95f5ea7c737a21cd6b9c59435ee693b3f127;p=u-boot
diff --git a/fs/zfs/zfs.c b/fs/zfs/zfs.c
index 360f723c84..818d3d926d 100644
--- a/fs/zfs/zfs.c
+++ b/fs/zfs/zfs.c
@@ -8,19 +8,7 @@
* Free Software Foundation, Inc.
* Copyright 2004 Sun Microsystems, Inc.
*
- * GRUB is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GRUB is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GRUB. If not, see .
- *
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include
@@ -30,6 +18,7 @@
#include
#include
#include "zfs_common.h"
+#include "div64.h"
block_dev_desc_t *zfs_dev_desc;
@@ -783,7 +772,7 @@ zap_leaf_array_equal(zap_leaf_phys_t *l, zfs_endian_t endian,
while (bseen < array_len) {
struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, blksft, chunk).l_array;
- int toread = MIN(array_len - bseen, ZAP_LEAF_ARRAY_BYTES);
+ int toread = min(array_len - bseen, ZAP_LEAF_ARRAY_BYTES);
if (chunk >= ZAP_LEAF_NUMCHUNKS(blksft))
return 0;
@@ -805,7 +794,7 @@ zap_leaf_array_get(zap_leaf_phys_t *l, zfs_endian_t endian, int blksft,
while (bseen < array_len) {
struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, blksft, chunk).l_array;
- int toread = MIN(array_len - bseen, ZAP_LEAF_ARRAY_BYTES);
+ int toread = min(array_len - bseen, ZAP_LEAF_ARRAY_BYTES);
if (chunk >= ZAP_LEAF_NUMCHUNKS(blksft))
/* Don't use errno because this error is to be ignored. */
@@ -2002,49 +1991,6 @@ zfs_fetch_nvlist(device_t dev, char **nvlist)
return err;
}
-static int
-zfs_label(device_t device, char **label)
-{
- char *nvlist;
- int err;
- struct zfs_data *data;
-
- data = zfs_mount(device);
- if (!data)
- return ZFS_ERR_BAD_FS;
-
- err = int_zfs_fetch_nvlist(data, &nvlist);
- if (err) {
- zfs_unmount(data);
- return err;
- }
-
- *label = zfs_nvlist_lookup_string(nvlist, ZPOOL_CONFIG_POOL_NAME);
- free(nvlist);
- zfs_unmount(data);
- return ZFS_ERR_NONE;
-}
-
-static int
-zfs_uuid(device_t device, char **uuid)
-{
- struct zfs_data *data;
-
- data = zfs_mount(device);
- if (!data)
- return ZFS_ERR_BAD_FS;
-
- *uuid = malloc(17); /* %016llx + nil */
- if (!*uuid)
- return ZFS_ERR_OUT_OF_MEMORY;
-
- /* *uuid = xasprintf ("%016llx", (long long unsigned) data->pool_guid);*/
- snprintf(*uuid, 17, "%016llx", (long long unsigned) data->pool_guid);
- zfs_unmount(data);
-
- return ZFS_ERR_NONE;
-}
-
/*
* zfs_open() locates a file in the rootpool by following the
* MOS and places the dnode of the file in the memory address DNODE.
@@ -2158,7 +2104,8 @@ zfs_read(zfs_file_t file, char *buf, uint64_t len)
/*
* Find requested blkid and the offset within that block.
*/
- uint64_t blkid = (file->offset + red) / blksz;
+ uint64_t blkid = file->offset + red;
+ blkid = do_div(blkid, blksz);
free(data->file_buf);
data->file_buf = 0;
@@ -2171,7 +2118,7 @@ zfs_read(zfs_file_t file, char *buf, uint64_t len)
data->file_start = blkid * blksz;
data->file_end = data->file_start + blksz;
- movesize = MIN(length, data->file_end - (int) file->offset - red);
+ movesize = min(length, data->file_end - (int)file->offset - red);
memmove(buf, data->file_buf + file->offset + red
- data->file_start, movesize);
@@ -2325,14 +2272,6 @@ zfs_ls(device_t device, const char *path,
struct zfs_data *data;
int err;
int isfs;
-#if 0
- char *label = NULL;
-
- zfs_label(device, &label);
- if (label)
- printf("ZPOOL label '%s'\n",
- label);
-#endif
data = zfs_mount(device);
if (!data)