1// Copyright 2017 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include <fs/service.h> 6 7namespace fs { 8 9Service::Service(Connector connector) 10 : connector_(fbl::move(connector)) {} 11 12Service::~Service() = default; 13 14zx_status_t Service::ValidateFlags(uint32_t flags) { 15 if (flags & ZX_FS_FLAG_DIRECTORY) { 16 return ZX_ERR_NOT_DIR; 17 } 18 return ZX_OK; 19} 20 21zx_status_t Service::Getattr(vnattr_t* attr) { 22 // TODO(ZX-1152): V_TYPE_FILE isn't right, we should use a type for services 23 memset(attr, 0, sizeof(vnattr_t)); 24 attr->mode = V_TYPE_FILE; 25 attr->nlink = 1; 26 return ZX_OK; 27} 28 29zx_status_t Service::Serve(Vfs* vfs, zx::channel channel, uint32_t flags) { 30 ZX_DEBUG_ASSERT(!(flags & ZX_FS_FLAG_DIRECTORY)); // checked by Open 31 32 if (!connector_) { 33 return ZX_ERR_NOT_SUPPORTED; 34 } 35 return connector_(fbl::move(channel)); 36} 37 38} // namespace fs 39